Find usage on Usage Plans and plans per API Key. Update `self.limits`.
351532
def _find_usage_plans(self):
        
        logger.debug('Finding usage for Usage Plans')
        plan_count = 0
        paginator = self.conn.get_paginator('get_usage_plans')
        for resp in paginator.paginate():
            plan_count += len(resp['items'])
        self.limits['Usage plans per account']._add_current_usage(
            plan_count, aws_type='AWS::ApiGateway::UsagePlan'
        )
212451
def set_limits(self, limits):
        

        # First task, build the checksum of the new limits
        chksum = hashlib.md5()  # sufficient for our purposes
        for lim in limits:
            chksum.update(lim)
        new_sum = chksum.hexdigest()

        # Now install it
        with self.limit_lock:
            if self.limit_sum == new_sum:
                # No changes
                return
            self.limit_data = [msgpack.loads(lim) for lim in limits]
            self.limit_sum = new_sum
419908
def _update_limits_from_api(self):
        
        self.connect()
        self.connect_resource()
        logger.info("Querying EC2 DescribeAccountAttributes for limits")
        # no need to paginate
        attribs = self.conn.describe_account_attributes()
        for attrib in attribs['AccountAttributes']:
            aname = attrib['AttributeName']
            val = attrib['AttributeValues'][0]['AttributeValue']
            lname = None
            if aname == 'max-elastic-ips':
                lname = 'Elastic IP addresses (EIPs)'
            elif aname == 'max-instances':
                lname = 'Running On-Demand EC2 instances'
            elif aname == 'vpc-max-elastic-ips':
                lname = 'VPC Elastic IP addresses (EIPs)'
            elif aname == 'vpc-max-security-groups-per-interface':
                lname = 'VPC security groups per elastic network interface'
            if lname is not None:
                if int(val) == 0:
                    continue
                self.limits[lname]._set_api_limit(int(val))
        logger.debug("Done setting limits from API")
1204467
def _find_usage_application_versions(self):
        """"""
        versions = self.conn.describe_application_versions()
        self.limits['Application versions']._add_current_usage(
            len(versions['ApplicationVersions']),
            aws_type='AWS::ElasticBeanstalk::ApplicationVersion',
        )
496549
def _update_callsafety(self, response):
        
        if self.ratelimit is not None:
            self.callsafety['lastcalltime'] = time()
            self.callsafety['lastlimitremaining'] = int(response.headers.get('X-Rate-Limit-Remaining', 0))
723030
def _find_limit_hosted_zone(self):
        
        for limit_type in [self.MAX_RRSETS_BY_ZONE,
                           self.MAX_VPCS_ASSOCIATED_BY_ZONE]:
            self.limits[limit_type["name"]]._reset_usage()

        for hosted_zone in self._get_hosted_zones():
            for limit_type in [self.MAX_RRSETS_BY_ZONE,
                               self.MAX_VPCS_ASSOCIATED_BY_ZONE]:

                if limit_type == self.MAX_VPCS_ASSOCIATED_BY_ZONE and \
                        not hosted_zone["Config"]["PrivateZone"]:
                    continue

                limit = self._get_hosted_zone_limit(limit_type["type"],
                                                    hosted_zone['Id'])

                self.limits[limit_type["name"]]._add_current_usage(
                    int(limit["Count"]),
                    maximum=int(limit["Limit"]["Value"]),
                    aws_type='AWS::Route53::HostedZone',
                    resource_id=hosted_zone["Name"]
                )
1013637
def delete_usage_plan(plan_id, region=None, key=None, keyid=None, profile=None):
    '''
    

    '''
    try:
        existing = describe_usage_plans(plan_id=plan_id, region=region, key=key, keyid=keyid, profile=profile)
        # don't attempt to delete the usage plan if it does not exist
        if 'error' in existing:
            return {'error': existing['error']}

        if 'plans' in existing and existing['plans']:
            conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
            res = conn.delete_usage_plan(usagePlanId=plan_id)
        return {'deleted': True, 'usagePlanId': plan_id}
    except ClientError as e:
        return {'error': __utils__['boto3.get_error'](e)}
59615
def show_usage(out = STDERR, width = 80)
            lines = ['']
            pos_args = positional_args
            opt_args = size - pos_args.size
            usage_args = pos_args.map(&:to_use)
            usage_args << (requires_some? ? 'OPTIONS' : '[OPTIONS]') if opt_args > 0
            usage_args << rest_args.to_use if rest_args?
            lines.concat(wrap_text("USAGE: #{RUBY_ENGINE} #{$0} #{usage_args.join(' ')}", width))
            lines << ''
            lines << 'Specify the /? or --help option for more detailed help'
            lines << ''
            lines.each{ |line| out.puts line } if out
            lines
        end
981993
def key_usage(self):
        """"""
        try:
            ext = self.x509.extensions.get_extension_for_oid(ExtensionOID.KEY_USAGE)
        except x509.ExtensionNotFound:
            return None
        return KeyUsage(ext)
421448
def _update_limits_from_api(self):
        
        self.connect()
        logger.info("Querying EC2 DescribeAccountAttributes for limits")
        lims = self.conn.describe_account_limits()
        self.limits['Auto Scaling groups']._set_api_limit(
            lims['MaxNumberOfAutoScalingGroups'])
        self.limits['Launch configurations']._set_api_limit(
            lims['MaxNumberOfLaunchConfigurations'])
937206
def find_usage(self):
        
        logger.debug("Checking usage for service %s", self.service_name)
        self.connect_resource()
        for lim in self.limits.values():
            lim._reset_usage()
        count = 0
        for bkt in self.resource_conn.buckets.all():
            count += 1
        self.limits['Buckets']._add_current_usage(
            count, aws_type='AWS::S3::Bucket'
        )
        self._have_usage = True
        logger.debug("Done checking usage.")
1167705
def _update_limits_from_api(self):
        
        self.connect()
        logger.info("Querying DynamoDB DescribeLimits for limits")
        # no need to paginate
        lims = self.conn.describe_limits()
        self.limits['Account Max Read Capacity Units']._set_api_limit(
            lims['AccountMaxReadCapacityUnits']
        )
        self.limits['Account Max Write Capacity Units']._set_api_limit(
            lims['AccountMaxWriteCapacityUnits']
        )
        self.limits['Table Max Read Capacity Units']._set_api_limit(
            lims['TableMaxReadCapacityUnits']
        )
        self.limits['Table Max Write Capacity Units']._set_api_limit(
            lims['TableMaxWriteCapacityUnits']
        )
        logger.debug("Done setting limits from API")
989075
def _update_data_dict(self, data_dict, back_or_front):
        
        data_dict['back_or_front'] = back_or_front
        # The percentage of used sessions based on 'scur' and 'slim'
        if 'slim' in data_dict and 'scur' in data_dict:
            try:
                data_dict['spct'] = (data_dict['scur'] / data_dict['slim']) * 100
            except (TypeError, ZeroDivisionError):
                pass
1134244
def find_usage(self):
        
        logger.debug("Checking usage for service %s", self.service_name)
        self.connect_resource()
        for lim in self.limits.values():
            lim._reset_usage()
        self._find_usage_dynamodb()
        self._have_usage = True
        logger.debug("Done checking usage.")
155343
def update_configuration(self, new_configuration):
        
        if new_configuration == self.configuration:
            return False
        now = timezone.now()
        if now.month != self.price_estimate.month:
            raise ConsumptionDetailUpdateError('It is possible to update consumption details only for current month.')
        minutes_from_last_update = self._get_minutes_from_last_update(now)
        for consumable_item, usage in self.configuration.items():
            consumed_after_modification = usage * minutes_from_last_update
            self.consumed_before_update[consumable_item] = (
                self.consumed_before_update.get(consumable_item, 0) + consumed_after_modification)
        self.configuration = new_configuration
        self.last_update_time = now
        self.save()
        return True
720900
def list_usages(location, custom_headers:nil)
      response = list_usages_async(location, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end
258781
def get_consumed(self, key):
        
        if key not in self._consumed:
            self._consumed[key] = {
                'read': DecayingCapacityStore(),
                'write': DecayingCapacityStore(),
            }
        return self._consumed[key]