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
1798
def _get_limit_check_id(self):
        
        logger.debug("Querying Trusted Advisor checks")
        try:
            checks = self.conn.describe_trusted_advisor_checks(
                language='en'
            )['checks']
        except ClientError as ex:
            if ex.response['Error']['Code'] == 'SubscriptionRequiredException':
                logger.warning(
                    "Cannot check TrustedAdvisor: %s",
                    ex.response['Error']['Message']
                )
                self.have_ta = False
                return (None, None)
            else:
                raise ex
        for check in checks:
            if (
                            check['category'] == 'performance' and
                            check['name'] == 'Service Limits'
            ):
                logger.debug("Found TA check; id=%s", check['id'])
                return (
                    check['id'],
                    check['metadata']
                )
        logger.debug("Unable to find check with category 'performance' and "
                     "name 'Service Limits'.")
        return (None, None)
105143
def details(
        self, *, limit: Optional[int] = 5, kind: Optional[TraceKind] = None
    ) -> None:
        
        self._verify_entrypoint_selected()
        if limit is not None and not isinstance(limit, int):
            raise UserError("'limit' should be an int or None.")
        if kind not in {TraceKind.PRECONDITION, TraceKind.POSTCONDITION, None}:
            raise UserError(
                "Try 'details kind=postcondition'" " or 'details kind=precondition'."
            )

        current_trace_tuple = self.trace_tuples[self.current_trace_frame_index]
        current_trace_frame = current_trace_tuple.trace_frame
        callable, _port = self._get_callable_from_trace_tuple(current_trace_tuple)

        print(self._create_trace_frame_output_string(current_trace_frame))
        print(
            f"\nIssues in callable ({callable}):",
            self._num_issues_with_callable(current_trace_frame.callee),
        )

        if kind is None or kind == TraceKind.POSTCONDITION:
            print(f"\nPostconditions with caller ({callable}):")
            self.frames(callers=callable, kind=TraceKind.POSTCONDITION, limit=limit)

        if kind is None or kind == TraceKind.PRECONDITION:
            print(f"\nPreconditions with caller ({callable}):")
            self.frames(callers=callable, kind=TraceKind.PRECONDITION, limit=limit)
707018
def _def_check(self):
        
        if self._def != dict():
            for key, val in iteritems_(self._def):
                if key not in list(TEXT_INDEX_ARGS.keys()):
                    raise CloudantArgumentError(127, key)
                if not isinstance(val, TEXT_INDEX_ARGS[key]):
                    raise CloudantArgumentError(128, key, TEXT_INDEX_ARGS[key])
1116485
def get_limits(self):
        
        logger.debug("Gathering %s's limits from AWS", self.service_name)

        if self.limits:
            return self.limits
        limits = {}

        limits['Trails Per Region'] = AwsLimit(
            'Trails Per Region',
            self,
            5,
            self.warning_threshold,
            self.critical_threshold,
            limit_type=self.aws_type
        )

        limits['Event Selectors Per Trail'] = AwsLimit(
            'Event Selectors Per Trail',
            self,
            5,
            self.warning_threshold,
            self.critical_threshold,
            limit_type=self.aws_type,
            limit_subtype='AWS::CloudTrail::EventSelector'
        )

        limits['Data Resources Per Trail'] = AwsLimit(
            'Data Resources Per Trail',
            self,
            250,
            self.warning_threshold,
            self.critical_threshold,
            limit_type=self.aws_type,
            limit_subtype='AWS::CloudTrail::DataResource'
        )

        self.limits = limits
        return limits
1177436
def requested_intervals(self, intervals):
        
        with switch_db(WorkflowStatusModel, db_alias='hyperstream'):
            workflow_statuses = WorkflowStatusModel.objects(workflow_id=self.workflow_id)
            if len(workflow_statuses) != 1:
                workflow_status = WorkflowStatusModel(
                    workflow_id=self.workflow_id,
                    requested_intervals=[]
                )

            else:
                workflow_status = workflow_statuses[0]

            workflow_status.last_updated = utcnow()
            workflow_status.last_accessed = utcnow()
            workflow_status.requested_intervals = tuple(
                map(lambda x: TimeIntervalModel(start=x.start, end=x.end), intervals))

            workflow_status.save()
1054830
def find_usage(self):
        
        logger.debug("Checking usage for service %s", self.service_name)
        for lim in self.limits.values():
            lim._reset_usage()
        try:
            self.connect()
            resp = self.conn.get_send_quota()
        except EndpointConnectionError as ex:
            logger.warning('Skipping SES: %s', str(ex))
            return
        except ClientError as ex:
            if ex.response['Error']['Code'] in ['AccessDenied', '503']:
                logger.warning('Skipping SES: %s', ex)
                return
            raise
        self.limits['Daily sending quota']._add_current_usage(
            resp['SentLast24Hours']
        )
        self._have_usage = True
        logger.debug("Done checking usage.")
1351244
def show_bandwidth_limit_rule(self, rule, policy, body=None):
        """"""
        return self.get(self.qos_bandwidth_limit_rule_path %
                        (policy, rule), body=body)
215563
def get_limits(self):
        
        if self.limits != {}:
            return self.limits
        limits = {}
        limits['Groups'] = AwsLimit(
            'Groups',
            self,
            300,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::Group',
        )
        limits['Users'] = AwsLimit(
            'Users',
            self,
            5000,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::User',
        )
        limits['Roles'] = AwsLimit(
            'Roles',
            self,
            1000,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::Role',
        )
        limits['Instance profiles'] = AwsLimit(
            'Instance profiles',
            self,
            1000,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::InstanceProfile',
        )
        limits['Server certificates'] = AwsLimit(
            'Server certificates',
            self,
            20,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::ServerCertificate',
        )
        limits['Policies'] = AwsLimit(
            'Policies',
            self,
            1500,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::Policy',
        )
        limits['Policy Versions In Use'] = AwsLimit(
            'Policy Versions In Use',
            self,
            10000,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::ServerCertificate',
        )
        self.limits = limits
        return limits
732608
def checks_list():
    '''
    
    '''
    application_url = _get_application_url()
    log.debug('[uptime] get checks')
    jcontent = requests.get('{0}/api/checks'.format(application_url)).json()
    return [x['url'] for x in jcontent]
274801
def list_bandwidth_limit_rules(self, policy_id,
                                   retrieve_all=True, **_params):
        """"""
        return self.list('bandwidth_limit_rules',
                         self.qos_bandwidth_limit_rules_path % policy_id,
                         retrieve_all, **_params)
1078515
def _get_limits_spot(self):
        
        limits = {}
        limits['Max spot instance requests per region'] = AwsLimit(
            'Max spot instance requests per region',
            self,
            20,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='Spot instance requests'
        )

        limits['Max active spot fleets per region'] = AwsLimit(
            'Max active spot fleets per region',
            self,
            1000,
            self.warning_threshold,
            self.critical_threshold,
        )

        limits['Max launch specifications per spot fleet'] = AwsLimit(
            'Max launch specifications per spot fleet',
            self,
            50,
            self.warning_threshold,
            self.critical_threshold,
        )

        limits['Max target capacity per spot fleet'] = AwsLimit(
            'Max target capacity per spot fleet',
            self,
            3000,
            self.warning_threshold,
            self.critical_threshold
        )

        limits['Max target capacity for all spot fleets in region'] = AwsLimit(
            'Max target capacity for all spot fleets in region',
            self,
            5000,
            self.warning_threshold,
            self.critical_threshold
        )
        return limits
631251
def rate_limiting(self):
        
        remaining, limit = self.__requester.rate_limiting
        if limit < 0:
            self.get_rate_limit()
        return self.__requester.rate_limiting
893198
def available_metrics(self):
        
        req = self.request(self.mist_client.uri+"/clouds/"+self.cloud.id+"/machines/"+self.id+"/metrics")
        metrics = req.get().json()
        return metrics
464034
def find_usage(self):
        
        logger.debug("Checking usage for service %s", self.service_name)
        self.connect()
        for lim in self.limits.values():
            lim._reset_usage()
        self._find_usage_instances()
        self._find_usage_subnet_groups()
        self._find_usage_security_groups()
        # RDS API also provides usage information
        self._update_limits_from_api()
        self._have_usage = True
        logger.debug("Done checking usage.")
185717
def found(self):
        
        if 'ids' in self.kwargs:
            cid = self.kwargs['query']['collection']['eq']
            return len(self.items_by_id(self.kwargs['ids'], cid))
        kwargs = {
            'page': 1,
            'limit': 0
        }
        kwargs.update(self.kwargs)
        results = self.query(**kwargs)
        return results['meta']['found']
1239318
def _calc_traceback_limit(tb):
    
    limit = 1
    tb2 = tb
    while not tb2.tb_next is None:
        try:
            maybe_pytypes = tb2.tb_next.tb_frame.f_code.co_filename.split(os.sep)[-2]
        except IndexError:
            maybe_pytypes = None
        if maybe_pytypes == 'pytypes' and not \
                tb2.tb_next.tb_frame.f_code == pytypes.typechecker._pytypes___import__.__code__:
            break
        else:
            limit += 1
            tb2 = tb2.tb_next
    return limit
287396
def find_usage(self):
        
        logger.debug("Checking usage for service %s", self.service_name)
        self.connect()
        for lim in self.limits.values():
            lim._reset_usage()
        self._find_usage_applications()
        self._find_usage_application_versions()
        self._find_usage_environments()
        self._have_usage = True
        logger.debug("Done checking usage.")