INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Validates error statuses.
def _check_status(status): """ Validates error statuses. """ status_code = status['code'] if status_code == 429: # Rate limit exceeded raise GeocoderQuotaExceeded( 'The given key has gone over the requests limit in the 24' '...
Return a location point by address.
def geocode( self, query, country_codes=None, exactly_one=True, timeout=DEFAULT_SENTINEL, ): """ Return a location point by address. :param str query: The address or query you wish to geocode. For a structured query, p...
Returns location ( latitude longitude ) from json feed.
def _parse_json(self, page, exactly_one): """Returns location, (latitude, longitude) from json feed.""" if not page.get('success'): return None latitude = page['latitude'] longitude = page['longitude'] place = page.get('place') address = ", ".join([place['c...
Return a location point for a 3 words query. If the 3 words address doesn t exist a: class: geopy. exc. GeocoderQueryError exception will be thrown.
def geocode(self, query, lang='en', exactly_one=True, timeout=DEFAULT_SENTINEL): """ Return a location point for a `3 words` query. If the `3 words` address doesn't exist, a :class:`geopy.exc.GeocoderQueryError` exception will be ...
Parse type words latitude and longitude and language from a JSON response.
def _parse_json(self, resources, exactly_one=True): """ Parse type, words, latitude, and longitude and language from a JSON response. """ code = resources['status'].get('code') if code: # https://docs.what3words.com/api/v2/#errors exc_msg = "Erro...
Return a 3 words address by location point. Each point on surface has a 3 words address so there s always a non - empty response.
def reverse(self, query, lang='en', exactly_one=True, timeout=DEFAULT_SENTINEL): """ Return a `3 words` address by location point. Each point on surface has a `3 words` address, so there's always a non-empty response. :param query: The coordinates for which you wish to o...
Return a location point by address.
def geocode( self, query, exactly_one=True, timeout=DEFAULT_SENTINEL, limit=None, addressdetails=False, language=False, geometry=None, extratags=False, country_codes=None, viewbox=None, ...
Return an address by location point.
def reverse( self, query, exactly_one=True, timeout=DEFAULT_SENTINEL, language=False, addressdetails=True ): """ Return an address by location point. :param query: The coordinates for which you wish to obtain the ...
Return a location point by address.
def geocode( self, query, exactly_one=True, timeout=DEFAULT_SENTINEL, location_bias=None, language=False, limit=None, osm_tag=None ): """ Return a location point by address. :param str query: The...
Parse display name latitude and longitude from a JSON response.
def _parse_json(cls, resources, exactly_one=True): """ Parse display name, latitude, and longitude from a JSON response. """ if not len(resources['features']): # pragma: no cover return None if exactly_one: return cls.parse_resource(resources['features'][...
Return an address by location point.
def reverse(self, query, exactly_one=True, timeout=DEFAULT_SENTINEL): """ Return an address by location point. :param query: The coordinates for which you wish to obtain the closest human-readable addresses. :type query: :class:`geopy.point.Point`, list or tuple of ``(latitu...
Parses a location from a single - result reverse API call.
def _parse_reverse_json(self, page, exactly_one=True): """ Parses a location from a single-result reverse API call. """ place = page.get('result') if not place: self._check_status(page.get('status')) return None location = place.get('formatted_ad...
Validates error statuses.
def _check_status(status): """ Validates error statuses. """ if status == 0: # When there are no results, just return. return if status == 1: raise GeocoderServiceError( 'Internal server error.' ) elif status...
Return a location point by address.
def geocode( self, query, exactly_one=True, timeout=DEFAULT_SENTINEL, limit=None, typeahead=False, language=None, ): """ Return a location point by address. :param str query: The address or query you wish to...
Return an address by location point.
def reverse( self, query, exactly_one=True, timeout=DEFAULT_SENTINEL, language=None, ): """ Return an address by location point. :param query: The coordinates for which you wish to obtain the closest human-readable addr...
Return a location point by address.
def geocode( self, query, query_type='StreetAddress', maximum_responses=25, is_freeform=False, filtering=None, exactly_one=True, timeout=DEFAULT_SENTINEL, ): """ Return a location point by address. ...
Return an address by location point.
def reverse( self, query, reverse_geocode_preference=('StreetAddress', ), maximum_responses=25, filtering='', exactly_one=DEFAULT_SENTINEL, timeout=DEFAULT_SENTINEL, ): """ Return an address by location point. ...
Returns location ( latitude longitude ) from XML feed and transform to json
def _parse_xml(self, page, is_reverse=False, is_freeform=False, exactly_one=True): """ Returns location, (latitude, longitude) from XML feed and transform to json """ # Parse the page tree = ET.fr...
Transform the xml ElementTree due to XML webservice return to json
def _xml_to_json_places(tree, is_reverse=False): """ Transform the xml ElementTree due to XML webservice return to json """ select_multi = ( 'GeocodedAddress' if not is_reverse else 'ReverseGeocodedLocation' ) adresses = tree.findall(...
Send the request to get raw content.
def _request_raw_content(self, url, timeout): """ Send the request to get raw content. """ request = Request(url) if self.referer is not None: request.add_header('Referer', self.referer) raw_xml = self._call_geocoder( request, timeou...
Get the location lat lng and place from a single json place.
def _parse_place(place, is_freeform=None): """ Get the location, lat, lng and place from a single json place. """ # When freeform already so full address if is_freeform == 'true': location = place.get('freeformaddress') else: # For parcelle ...
Return a location point by address.
def geocode( self, query, exactly_one=True, timeout=DEFAULT_SENTINEL, country=None, country_bias=None, ): """ Return a location point by address. :param str query: The address or query you wish to geocode. :par...
Return an address by location point.
def reverse( self, query, exactly_one=DEFAULT_SENTINEL, timeout=DEFAULT_SENTINEL, feature_code=None, lang=None, find_nearby_type='findNearbyPlaceName', ): """ Return an address by location point. .. vers...
Find the timezone for a point in query.
def reverse_timezone(self, query, timeout=DEFAULT_SENTINEL): """ Find the timezone for a point in `query`. GeoNames always returns a timezone: if the point being queried doesn't have an assigned Olson timezone id, a ``pytz.FixedOffset`` timezone is used to produce the :class:`ge...
Parse JSON response body.
def _parse_json(self, doc, exactly_one): """ Parse JSON response body. """ places = doc.get('geonames', []) self._raise_for_error(doc) if not len(places): return None def parse_code(place): """ Parse each record. ""...
Return a location point by address.
def geocode( self, query, exactly_one=True, timeout=DEFAULT_SENTINEL, boundary_rect=None, country_bias=None, ): """ Return a location point by address. :param str query: The address, query or structured query to geocode...
Returns location ( latitude longitude ) from json feed.
def _parse_json(self, json, exactly_one=True): '''Returns location, (latitude, longitude) from json feed.''' features = json['features'] if features == []: return None def parse_feature(feature): location = feature['place_name'] place = feature['text'...
Return a location point by address
def geocode( self, query, exactly_one=True, timeout=DEFAULT_SENTINEL, proximity=None, country=None, bbox=None, ): """ Return a location point by address :param str query: The address or query you wish to geo...
Return an address by location point.
def reverse( self, query, exactly_one=True, timeout=DEFAULT_SENTINEL, ): """ Return an address by location point. :param query: The coordinates for which you wish to obtain the closest human-readable addresses. :type query:...
For the service provided try to return a geocoder class.
def get_geocoder_for_service(service): """ For the service provided, try to return a geocoder class. >>> from geopy.geocoders import get_geocoder_for_service >>> get_geocoder_for_service("nominatim") geopy.geocoders.osm.Nominatim If the string given is not recognized, a :class:`geopy.exc.G...
Return an address by location point.
def reverse( self, query, exactly_one=DEFAULT_SENTINEL, timeout=DEFAULT_SENTINEL, kind=None, ): """ Return an address by location point. :param query: The coordinates for which you wish to obtain the closest human-reada...
Parse JSON response body.
def _parse_json(self, doc, exactly_one): """ Parse JSON response body. """ if doc.get('error'): raise GeocoderServiceError(doc['error']['message']) try: places = doc['response']['GeoObjectCollection']['featureMember'] except KeyError: ...
TODO docs.
def format_degrees(degrees, fmt=DEGREES_FORMAT, symbols=None): """ TODO docs. """ symbols = symbols or ASCII_SYMBOLS arcminutes = units.arcminutes(degrees=degrees - int(degrees)) arcseconds = units.arcseconds(arcminutes=arcminutes - int(arcminutes)) format_dict = dict( symbols, ...
TODO docs.
def format_distance(kilometers, fmt=DISTANCE_FORMAT, unit='km'): """ TODO docs. """ magnitude = DISTANCE_UNITS[unit](kilometers) return fmt % {'magnitude': magnitude, 'unit': unit}
If self. _savepath doesn t exist can t be read as JSON or doesn t match VERSION return 0. Otherwise return the step which that file lists as the last - run step for this release.
def _last_step(self): """ If ``self._savepath`` doesn't exist, can't be read as JSON, or doesn't match ``VERSION``, return 0. Otherwise, return the step which that file lists as the last-run step for this release. :return: last-run step from the release or 0 :rtype: int ...
Given a build object find the acceptance36 job
def _find_travis_job(self, build, toxenv): """Given a build object, find the acceptance36 job""" for jobid in build.job_ids: j = self._travis.job(jobid) if 'TOXENV=%s' % toxenv in j.config['env']: logger.debug('Found %s job: %s', toxenv, j.number) ...
Run the specified tox environment.
def _run_tox_env(self, env_name, extra_env_vars={}): """ Run the specified tox environment. :param env_name: name of the tox environment to run :type env_name: str :param extra_env_vars: additional variables to set in the environment :type extra_env_vars: dict :r...
Return the current PATH fixed to remove the docker tox env.
def _fixed_path(self, projdir): """ Return the current PATH, fixed to remove the docker tox env. :return: sanitized path :rtype: str """ res = [] toxdir = os.path.join(projdir, '.tox') for p in os.environ['PATH'].split(':'): if not p.startswit...
Determine the current usage for each limit of this service and update corresponding Limit via: py: meth: ~. AwsLimit. _add_current_usage.
def find_usage(self): """ Determine the current usage for each limit of this service, and update corresponding Limit via :py:meth:`~.AwsLimit._add_current_usage`. """ logger.debug("Getting usage for Lambda metrics") try: self.connect() resp...
Return all known limits for this service as a dict of their names to: py: class: ~. AwsLimit objects.
def get_limits(self): """ Return all known limits for this service, as a dict of their names to :py:class:`~.AwsLimit` objects. :returns: dict of limit names to :py:class:`~.AwsLimit` objects :rtype: dict """ logger.debug("Getting limits for Lambda") if s...
Query Lambda s DescribeLimits API action and update limits with the quotas returned. Updates self. limits.
def _update_limits_from_api(self): """ Query Lambda's DescribeLimits API action, and update limits with the quotas returned. Updates ``self.limits``. """ logger.debug("Updating limits for Lambda from the AWS API") if len(self.limits) == 2: return self....
Determine the current usage for each limit of this service and update corresponding Limit via: py: meth: ~. AwsLimit. _add_current_usage.
def find_usage(self): """ Determine the current usage for each limit of this service, and update corresponding Limit via :py:meth:`~.AwsLimit._add_current_usage`. """ logger.debug("Checking usage for service %s", self.service_name) self.connect() for lim i...
Return all known limits for this service as a dict of their names to: py: class: ~. AwsLimit objects.
def get_limits(self): """ Return all known limits for this service, as a dict of their names to :py:class:`~.AwsLimit` objects. :returns: dict of limit names to :py:class:`~.AwsLimit` objects :rtype: dict """ if self.limits != {}: return self.limits ...
Query EC2 s DescribeAccountAttributes API action and update limits with the quotas returned. Updates self. limits.
def _update_limits_from_api(self): """ Query EC2's DescribeAccountAttributes API action, and update limits with the quotas returned. Updates ``self.limits``. """ self.connect() logger.info("Querying EC2 DescribeAccountAttributes for limits") lims = self.conn.descr...
Find the ECS service usage for clusters. Calls: py: meth: ~. _find_usage_one_cluster for each cluster.
def _find_usage_clusters(self): """ Find the ECS service usage for clusters. Calls :py:meth:`~._find_usage_one_cluster` for each cluster. """ count = 0 fargate_task_count = 0 paginator = self.conn.get_paginator('list_clusters') for page in paginator.pagina...
Find usage for services in each cluster.
def _find_usage_one_cluster(self, cluster_name): """ Find usage for services in each cluster. :param cluster_name: name of the cluster to find usage for :type cluster_name: str """ tps_lim = self.limits['EC2 Tasks per Service (desired count)'] paginator = self.co...
Determine the current usage for each limit of this service and update corresponding Limit via: py: meth: ~. AwsLimit. _add_current_usage.
def find_usage(self): """ Determine the current usage for each limit of this service, and update corresponding Limit via :py:meth:`~.AwsLimit._add_current_usage`. """ logger.debug("Checking usage for service %s", self.service_name) self.connect() for lim i...
Find usage on APIs/ RestAPIs and resources that are limited per - API. Update self. limits.
def _find_usage_apis(self): """ Find usage on APIs / RestAPIs, and resources that are limited per-API. Update `self.limits`. """ api_ids = [] logger.debug('Finding usage for APIs') regional_count = 0 private_count = 0 edge_count = 0 paginat...
Find usage on API Keys. Update self. limits.
def _find_usage_api_keys(self): """ Find usage on API Keys. Update `self.limits`. """ logger.debug('Finding usage for API Keys') key_count = 0 paginator = self.conn.get_paginator('get_api_keys') for resp in paginator.paginate(): key_count += le...
Find usage on Client Certificates. Update self. limits.
def _find_usage_certs(self): """ Find usage on Client Certificates. Update `self.limits`. """ logger.debug('Finding usage for Client Certificates') cert_count = 0 paginator = self.conn.get_paginator('get_client_certificates') for resp in paginator.paginate(): ...
Find usage on VPC Links. Update self. limits.
def _find_usage_vpc_links(self): """ Find usage on VPC Links. Update `self.limits`. """ logger.debug('Finding usage for VPC Links') link_count = 0 paginator = self.conn.get_paginator('get_vpc_links') for resp in paginator.paginate(): link_count += len(...
Find usage on Usage Plans and plans per API Key. Update self. limits.
def _find_usage_plans(self): """ Find usage on Usage Plans and plans per API Key. Update `self.limits`. """ logger.debug('Finding usage for Usage Plans') plan_count = 0 paginator = self.conn.get_paginator('get_usage_plans') for resp in paginator.paginate(): ...
Determine the current usage for each limit of this service and update corresponding Limit via: py: meth: ~. AwsLimit. _add_current_usage.
def find_usage(self): """ Determine the current usage for each limit of this service, and update corresponding Limit via :py:meth:`~.AwsLimit._add_current_usage`. """ logger.debug("Checking usage for service %s", self.service_name) self.connect() for lim i...
Call: py: meth: ~. connect and then check what region we re running in ; adjust default limits as required for regions that differ ( us - east - 1 ).
def _update_limits_from_api(self): """ Call :py:meth:`~.connect` and then check what region we're running in; adjust default limits as required for regions that differ (us-east-1). """ region_limits = { 'us-east-1': 70 } self.connect() rname = ...
Poll Service Limits check results from Trusted Advisor if possible. Iterate over all: py: class: ~. AwsLimit objects for the given services and update their limits from TA if present in TA checks.
def update_limits(self): """ Poll 'Service Limits' check results from Trusted Advisor, if possible. Iterate over all :py:class:`~.AwsLimit` objects for the given services and update their limits from TA if present in TA checks. :param services: dict of service name (string) to ...
Poll Trusted Advisor ( Support ) API for limit checks.
def _poll(self): """ Poll Trusted Advisor (Support) API for limit checks. Return a dict of service name (string) keys to nested dict vals, where each key is a limit name and each value the current numeric limit. e.g.: :: { 'EC2': { ...
Query currently - available TA checks return the check ID and metadata of the performance/ Service Limits check.
def _get_limit_check_id(self): """ Query currently-available TA checks, return the check ID and metadata of the 'performance/Service Limits' check. :returns: 2-tuple of Service Limits TA check ID (string), metadata (list), or (None, None). :rtype: tuple """ ...
Given the check_id return the dict of Trusted Advisor check results. This handles refreshing the Trusted Advisor check if desired according to self. refresh_mode and self. refresh_timeout.
def _get_refreshed_check_result(self, check_id): """ Given the ``check_id``, return the dict of Trusted Advisor check results. This handles refreshing the Trusted Advisor check, if desired, according to ``self.refresh_mode`` and ``self.refresh_timeout``. :param check_id: the Tru...
Given a Trusted Advisor check_id that has just been refreshed poll until the refresh is complete. Once complete return the check result.
def _poll_for_refresh(self, check_id): """ Given a Trusted Advisor check_id that has just been refreshed, poll until the refresh is complete. Once complete, return the check result. :param check_id: the Trusted Advisor check ID :type check_id: str :returns: dict check re...
Determine if the given check_id can be refreshed yet.
def _can_refresh_check(self, check_id): """ Determine if the given check_id can be refreshed yet. :param check_id: the Trusted Advisor check ID :type check_id: str :return: whether or not the check can be refreshed yet :rtype: bool """ try: re...
Directly wrap: py: meth: Support. Client. describe_trusted_advisor_check_result ; return a 2 - tuple of the result dict and the last refresh DateTime.
def _get_check_result(self, check_id): """ Directly wrap :py:meth:`Support.Client.describe_trusted_advisor_check_result`; return a 2-tuple of the result dict and the last refresh DateTime. :param check_id: the Trusted Advisor check ID :type check_id: str :return:...
Given a dict of TrustedAdvisor check results from: py: meth: ~. _poll and a dict of Service objects passed in to: py: meth: ~. update_limits updated the TrustedAdvisor limits for all services.
def _update_services(self, ta_results): """ Given a dict of TrustedAdvisor check results from :py:meth:`~._poll` and a dict of Service objects passed in to :py:meth:`~.update_limits`, updated the TrustedAdvisor limits for all services. :param ta_results: results returned by :py:...
Build our service and limits dict. This is laid out identical to self. all_services but keys limits by their ta_service_name and ta_limit_name properties.
def _make_ta_service_dict(self): """ Build our service and limits dict. This is laid out identical to ``self.all_services``, but keys limits by their ``ta_service_name`` and ``ta_limit_name`` properties. :return: dict of TA service names to TA limit names to AwsLimit objects. ...
Determine the current usage for each limit of this service and update corresponding Limit via: py: meth: ~. AwsLimit. _add_current_usage.
def find_usage(self): """ Determine the current usage for each limit of this service, and update corresponding Limit via :py:meth:`~.AwsLimit._add_current_usage`. """ logger.debug("Checking usage for service %s", self.service_name) self.connect() for lim i...
find usage for ElasticBeanstalk applications
def _find_usage_applications(self): """find usage for ElasticBeanstalk applications""" applications = self.conn.describe_applications() self.limits['Applications']._add_current_usage( len(applications['Applications']), aws_type='AWS::ElasticBeanstalk::Application', ...
find usage for ElasticBeanstalk application verions
def _find_usage_application_versions(self): """find usage for ElasticBeanstalk application verions""" versions = self.conn.describe_application_versions() self.limits['Application versions']._add_current_usage( len(versions['ApplicationVersions']), aws_type='AWS::ElasticB...
find usage for ElasticBeanstalk environments
def _find_usage_environments(self): """find usage for ElasticBeanstalk environments""" environments = self.conn.describe_environments() self.limits['Environments']._add_current_usage( len(environments['Environments']), aws_type='AWS::ElasticBeanstalk::Environment', ...
format command output for docs
def format_cmd_output(cmd, output, name): """format command output for docs""" formatted = '.. code-block:: console\n\n' formatted += ' (venv)$ {c}\n'.format(c=cmd) lines = output.split("\n") if name != 'help': for idx, line in enumerate(lines): if len(line) > 100: ...
Trigger rebuild of all documentation that is dynamically generated from awslimitchecker.
def build_docs(): """ Trigger rebuild of all documentation that is dynamically generated from awslimitchecker. """ if os.environ.get('CI', None) is not None: print("Not building dynamic docs in CI environment") raise SystemExit(0) region = os.environ.get('AWS_DEFAULT_REGION', Non...
Determine the current usage for each limit of this service and update corresponding Limit via: py: meth: ~. AwsLimit. _add_current_usage.
def find_usage(self): """ Determine the current usage for each limit of this service, and update corresponding Limit via :py:meth:`~.AwsLimit._add_current_usage`. """ logger.debug("Checking usage for service %s", self.service_name) self.connect() for lim i...
find usage for VPCs
def _find_usage_vpcs(self): """find usage for VPCs""" # overall number of VPCs vpcs = self.conn.describe_vpcs() self.limits['VPCs']._add_current_usage( len(vpcs['Vpcs']), aws_type='AWS::EC2::VPC' )
find usage for Subnets ; return dict of SubnetId to AZ
def _find_usage_subnets(self): """find usage for Subnets; return dict of SubnetId to AZ""" # subnets per VPC subnet_to_az = {} subnets = defaultdict(int) for subnet in self.conn.describe_subnets()['Subnets']: subnets[subnet['VpcId']] += 1 subnet_to_az[subn...
find usage for ACLs
def _find_usage_ACLs(self): """find usage for ACLs""" # Network ACLs per VPC acls = defaultdict(int) for acl in self.conn.describe_network_acls()['NetworkAcls']: acls[acl['VpcId']] += 1 # Rules per network ACL self.limits['Rules per network ACL']._add_...
find usage for route tables
def _find_usage_route_tables(self): """find usage for route tables""" # Route tables per VPC tables = defaultdict(int) for table in self.conn.describe_route_tables()['RouteTables']: tables[table['VpcId']] += 1 # Entries per route table routes = [ ...
find usage for Internet Gateways
def _find_usage_gateways(self): """find usage for Internet Gateways""" # Internet gateways gws = self.conn.describe_internet_gateways() self.limits['Internet gateways']._add_current_usage( len(gws['InternetGateways']), aws_type='AWS::EC2::InternetGateway', ...
find usage for NAT Gateways
def _find_usage_nat_gateways(self, subnet_to_az): """ find usage for NAT Gateways :param subnet_to_az: dict mapping subnet ID to AZ :type subnet_to_az: dict """ # currently, some regions (sa-east-1 as one example) don't have NAT # Gateway service; they return an ...
find usage of vpn gateways
def _find_usages_vpn_gateways(self): """find usage of vpn gateways""" # do not include deleting and deleted in the results vpngws = self.conn.describe_vpn_gateways(Filters=[ { 'Name': 'state', 'Values': [ 'available', ...
find usage of network interfaces
def _find_usage_network_interfaces(self): """find usage of network interfaces""" enis = paginate_dict( self.conn.describe_network_interfaces, alc_marker_path=['NextToken'], alc_data_path=['NetworkInterfaces'], alc_marker_param='NextToken' ) ...
Query EC2 s DescribeAccountAttributes API action and update the network interface limit as needed. Updates self. limits.
def _update_limits_from_api(self): """ Query EC2's DescribeAccountAttributes API action and update the network interface limit, as needed. Updates ``self.limits``. More info on the network interface limit, from the docs: 'This limit is the greater of either the default limit (35...
Determine the current usage for each limit of this service and update corresponding Limit via: py: meth: ~. AwsLimit. _add_current_usage.
def find_usage(self): """ Determine the current usage for each limit of this service, and update corresponding Limit via :py:meth:`~.AwsLimit._add_current_usage`. """ logger.debug("Checking usage for service %s", self.service_name) self.connect() for lim i...
Call the service s API action to retrieve limit/ quota information and update AwsLimit objects in self. limits with this information.
def _update_limits_from_api(self): """ Call the service's API action to retrieve limit/quota information, and update AwsLimit objects in ``self.limits`` with this information. """ logger.debug('Setting DirectoryService limits from API') self.connect() resp = self....
Determine the current usage for each limit of this service and update corresponding Limit via: py: meth: ~. AwsLimit. _add_current_usage.
def find_usage(self): """ Determine the current usage for each limit of this service, and update corresponding Limit via :py:meth:`~.AwsLimit._add_current_usage`. """ ignore_statuses = [ 'DELETE_COMPLETE' ] logger.debug("Checking usage for serv...
Call the service s API action to retrieve limit/ quota information and update AwsLimit objects in self. limits with this information.
def _update_limits_from_api(self): """ Call the service's API action to retrieve limit/quota information, and update AwsLimit objects in ``self.limits`` with this information. """ logger.debug('Setting CloudFormation limits from API') self.connect() resp = self.co...
Set a new value for this limit to override the default ( such as when AWS Support has increased a limit of yours ). If override_ta is True this value will also supersede any found through Trusted Advisor.
def set_limit_override(self, limit_value, override_ta=True): """ Set a new value for this limit, to override the default (such as when AWS Support has increased a limit of yours). If ``override_ta`` is True, this value will also supersede any found through Trusted Advisor. ...
Return: py: const: ~awslimitchecker. limit. SOURCE_DEFAULT if: py: meth: ~. get_limit returns the default limit: py: const: ~awslimitchecker. limit. SOURCE_OVERRIDE if it returns a manually - overridden limit: py: const: ~awslimitchecker. limit. SOURCE_TA if it returns a limit from Trusted Advisor or: py: const: ~awsli...
def get_limit_source(self): """ Return :py:const:`~awslimitchecker.limit.SOURCE_DEFAULT` if :py:meth:`~.get_limit` returns the default limit, :py:const:`~awslimitchecker.limit.SOURCE_OVERRIDE` if it returns a manually-overridden limit, :py:const:`~awslimitchecker.limit.SO...
Returns the effective limit value for this Limit taking into account limit overrides and Trusted Advisor data. None is returned for limits that are explicitly unlimited.
def get_limit(self): """ Returns the effective limit value for this Limit, taking into account limit overrides and Trusted Advisor data. None is returned for limits that are explicitly unlimited. :returns: effective limit value, ``int`` or ``None`` """ li...
Get the a string describing the current usage for this limit.
def get_current_usage_str(self): """ Get the a string describing the current usage for this limit. If no usage has been added for this limit, the result will be "<unknown>". If the limit has only one current usage instance, this will be that instance's :py:meth:`~.AwsLi...
Add a new current usage value for this limit.
def _add_current_usage(self, value, maximum=None, resource_id=None, aws_type=None): """ Add a new current usage value for this limit. Creates a new :py:class:`~.AwsLimitUsage` instance and appends it to the internal list. If more than one usage value i...
Get the warning and critical thresholds for this Limit.
def _get_thresholds(self): """ Get the warning and critical thresholds for this Limit. Return type is a 4-tuple of: 1. warning integer (usage) threshold, or None 2. warning percent threshold 3. critical integer (usage) threshold, or None 4. critical percent thre...
Override the default warning and critical thresholds used to evaluate this limit s usage. Theresholds can be specified as a percentage of the limit or as a usage count or both.
def set_threshold_override(self, warn_percent=None, warn_count=None, crit_percent=None, crit_count=None): """ Override the default warning and critical thresholds used to evaluate this limit's usage. Theresholds can be specified as a percentage of the limit...
Check this limit s current usage against the specified default thresholds and any custom theresholds that have been set on the class instance. Return True if usage is within thresholds or false if warning or critical thresholds have been surpassed.
def check_thresholds(self): """ Check this limit's current usage against the specified default thresholds, and any custom theresholds that have been set on the class instance. Return True if usage is within thresholds, or false if warning or critical thresholds have been surpasse...
Determine the current usage for each limit of this service and update corresponding Limit via: py: meth: ~. AwsLimit. _add_current_usage.
def find_usage(self): """ Determine the current usage for each limit of this service, and update corresponding Limit via :py:meth:`~.AwsLimit._add_current_usage`. """ logger.debug("Checking usage for service %s", self.service_name) self.connect() for lim i...
find usage for cache nodes
def _find_usage_nodes(self): """find usage for cache nodes""" nodes = 0 paginator = self.conn.get_paginator('describe_cache_clusters') for page in paginator.paginate(ShowCacheNodeInfo=True): for cluster in page['CacheClusters']: try: num_no...
find usage for elasticache parameter groups
def _find_usage_parameter_groups(self): """find usage for elasticache parameter groups""" num_groups = 0 paginator = self.conn.get_paginator('describe_cache_parameter_groups') for page in paginator.paginate(): for group in page['CacheParameterGroups']: num_gr...
find usage for elasticache security groups
def _find_usage_security_groups(self): """find usage for elasticache security groups""" num_groups = 0 # If EC2-Classic isn't available (e.g., a new account) # this method will fail with: # Code: "InvalidParameterValue" # Message: "Use of cache security groups is n...
Determine the current usage for each limit of this service and update corresponding Limit via: py: meth: ~. AwsLimit. _add_current_usage.
def find_usage(self): """ Determine the current usage for each limit of this service, and update corresponding Limit via :py:meth:`~.AwsLimit._add_current_usage`. """ logger.debug("Checking usage for service %s", self.service_name) for lim in self.limits.values():...
Return all known limits for this service as a dict of their names to: py: class: ~. AwsLimit objects.
def get_limits(self): """ Return all known limits for this service, as a dict of their names to :py:class:`~.AwsLimit` objects. :returns: dict of limit names to :py:class:`~.AwsLimit` objects :rtype: dict """ if self.limits != {}: return self.limits ...
Call the service s API action to retrieve limit/ quota information and update AwsLimit objects in self. limits with this information.
def _update_limits_from_api(self): """ Call the service's API action to retrieve limit/quota information, and update AwsLimit objects in ``self.limits`` with this information. """ self.connect_resource() summary = self.resource_conn.AccountSummary() for k, v in so...
parse arguments/ options
def parse_args(self, argv): """ parse arguments/options :param argv: argument list to parse, usually ``sys.argv[1:]`` :type argv: list :returns: parsed arguments :rtype: :py:class:`argparse.Namespace` """ desc = 'Report on AWS service limits and usage via...
: param service_name: the name of the service: type service_name: str: param limit: the Limit this relates to: type limit:: py: class: ~. AwsLimit: param crits: the specific usage values that crossed the critical threshold: type usage:: py: obj: list of: py: class: ~. AwsLimitUsage: param crits: the specific usage valu...
def print_issue(self, service_name, limit, crits, warns): """ :param service_name: the name of the service :type service_name: str :param limit: the Limit this relates to :type limit: :py:class:`~.AwsLimit` :param crits: the specific usage values that crossed the critical...