Query EC2's DescribeAccountAttributes API action, and update limits
        with the quotas returned. Updates ``self.limits``.
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'])
541661
public function update($quotaId, $aclId, AclBuilder $input, array $queryParams = [])
    {
        $response = $this->api->quotas()->acls()->update($quotaId, $aclId, $input->toArray(), $queryParams);

        return new AclResponse($response);
    }
161404
def add_quota(self, quota):
        """"""
        if quota.limit in (None, -1, float('inf')):
            # Handle "unlimited" quotas.
            self.usages[quota.name]['quota'] = float("inf")
            self.usages[quota.name]['available'] = float("inf")
        else:
            self.usages[quota.name]['quota'] = int(quota.limit)
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
598322
def update_attributes(self, id, old_attrs, new_attrs):
        
        update = dict()
        set_value = {'attributes.' + k: v for k, v in new_attrs.items() if v is not None}
        if set_value:
            update['$set'] = set_value
        unset_value = {'attributes.' + k: v for k, v in new_attrs.items() if v is None}
        if unset_value:
            update['$unset'] = unset_value

        if update:
            response = self.get_db().alerts.update_one({'_id': {'$regex': '^' + id}}, update=update)
            return response.matched_count > 0
1269489
def _update_limits_from_api(self):
        
        self.connect()
        logger.debug("Querying ELB DescribeAccountLimits for limits")
        attribs = self.conn.describe_account_limits()
        name_to_limits = {
            'classic-load-balancers': 'Active load balancers',
            'classic-listeners': 'Listeners per load balancer',
            'classic-registered-instances':
                'Registered instances per load balancer'
        }
        for attrib in attribs['Limits']:
            if int(attrib.get('Max', 0)) == 0:
                continue
            name = attrib.get('Name', 'unknown')
            if name not in name_to_limits:
                continue
            self.limits[name_to_limits[name]]._set_api_limit(int(attrib['Max']))
        # connect to ELBv2 API as well
        self.conn2 = client('elbv2', **self._boto3_connection_kwargs)
        logger.debug("Connected to %s in region %s",
                     'elbv2', self.conn2._client_config.region_name)
        logger.debug("Querying ELBv2 (ALB) DescribeAccountLimits for limits")
        attribs = self.conn2.describe_account_limits()
        name_to_limits = {
            'target-groups': 'Target groups',
            'listeners-per-application-load-balancer':
                'Listeners per application load balancer',
            'rules-per-application-load-balancer':
                'Rules per application load balancer',
            'network-load-balancers': 'Network load balancers',
            'listeners-per-network-load-balancer':
                'Listeners per network load balancer'
        }
        for attrib in attribs['Limits']:
            if int(attrib.get('Max', 0)) == 0:
                continue
            name = attrib.get('Name', 'unknown')
            if name not in name_to_limits:
                continue
            self.limits[name_to_limits[name]]._set_api_limit(int(attrib['Max']))
        logger.debug("Done setting limits from API")
732160
public SamplingRuleUpdate withAttributes(java.util.Map<String, String> attributes) {
        setAttributes(attributes);
        return this;
    }
9816
public void updateCount(String lastPrefix, int diff) {
        String statNode = Quotas.statPath(lastPrefix);
        DataNode node = nodes.get(statNode);
        StatsTrack updatedStat = null;
        if (node == null) {
            // should not happen
            LOG.error("Missing count node for stat " + statNode);
            return;
        }
        synchronized (node) {
            updatedStat = new StatsTrack(new String(node.data));
            updatedStat.setCount(updatedStat.getCount() + diff);
            node.data = updatedStat.toString().getBytes();
        }
        // now check if the counts match the quota
        String quotaNode = Quotas.quotaPath(lastPrefix);
        node = nodes.get(quotaNode);
        StatsTrack thisStats = null;
        if (node == null) {
            // should not happen
            LOG.error("Missing count node for quota " + quotaNode);
            return;
        }
        synchronized (node) {
            thisStats = new StatsTrack(new String(node.data));
        }
        if (thisStats.getCount() < updatedStat.getCount()) {
            LOG
                    .warn("Quota exceeded: " + lastPrefix + " count="
                            + updatedStat.getCount() + " limit="
                            + thisStats.getCount());
        }
    }
1224577
def update(self, attributes=None):
        

        if attributes is None:
            attributes = {}

        headers = self.__class__.create_headers(attributes)
        headers.update(self._update_headers())

        result = self._client._put(
            self._update_url(),
            self.__class__.create_attributes(attributes, self),
            headers=headers
        )

        self._update_from_resource(result)

        return self
504632
def update_instances(self):
        
        self.log.debug('Updating EC2Instances for {}/{}'.format(self.account.account_name, self.region))
        ec2 = self.session.resource('ec2', region_name=self.region)

        try:
            existing_instances = EC2Instance.get_all(self.account, self.region)
            instances = {}
            api_instances = {x.id: x for x in ec2.instances.all()}

            try:
                for instance_id, data in api_instances.items():
                    if data.instance_id in existing_instances:
                        instance = existing_instances[instance_id]

                        if data.state['Name'] not in ('terminated', 'shutting-down'):
                            instances[instance_id] = instance

                            # Add object to transaction if it changed
                            if instance.update(data):
                                self.log.debug('Updating info for instance {} in {}/{}'.format(
                                    instance.resource.resource_id,
                                    self.account.account_name,
                                    self.region
                                ))
                                db.session.add(instance.resource)
                    else:
                        # New instance, if its not in state=terminated
                        if data.state['Name'] in ('terminated', 'shutting-down'):
                            continue

                        tags = {tag['Key']: tag['Value'] for tag in data.tags or {}}
                        properties = {
                            'launch_date': to_utc_date(data.launch_time).isoformat(),
                            'state': data.state['Name'],
                            'instance_type': data.instance_type,
                            'public_ip': getattr(data, 'public_ip_address', None),
                            'public_dns': getattr(data, 'public_dns_address', None),
                            'created': isoformat(datetime.now())
                        }

                        instance = EC2Instance.create(
                            data.instance_id,
                            account_id=self.account.account_id,
                            location=self.region,
                            properties=properties,
                            tags=tags
                        )

                        instances[instance.resource.resource_id] = instance
                        self.log.debug('Added new EC2Instance {}/{}/{}'.format(
                            self.account.account_name,
                            self.region,
                            instance.resource.resource_id
                        ))

                # Check for deleted instances
                ik = set(list(instances.keys()))
                eik = set(list(existing_instances.keys()))

                for instanceID in eik - ik:
                    db.session.delete(existing_instances[instanceID].resource)
                    self.log.debug('Deleted EC2Instance {}/{}/{}'.format(
                        self.account.account_name,
                        self.region,
                        instanceID
                    ))

                db.session.commit()
            except:
                db.session.rollback()
                raise
        finally:
            del ec2
885779
def set_public_limits(self):
        
        if self.request.method.upper() in ['GET', 'HEAD']:
            self._query_params.process_int_param('_limit', 20)
        if self._auth_enabled and not getattr(self.request, 'user', None):
            wrappers.set_public_limits(self)
674063
def set_quota(self, quota_bytes):
        
        self.set_library_metadata(ArcticLibraryBinding.QUOTA, quota_bytes)
        self.quota = quota_bytes
        self.quota_countdown = 0
882805
def update_elbs(self):
        
        self.log.debug('Updating ELBs for {}/{}'.format(
            self.account.account_name,
            self.region
        ))

        # ELBs known to CINQ
        elbs_from_db = ELB.get_all(self.account, self.region)
        try:

            # ELBs known to AWS
            elb_client = self.session.client('elb', region_name=self.region)
            load_balancer_instances = elb_client.describe_load_balancers()['LoadBalancerDescriptions']
            elbs_from_api = {}
            for load_balancer in load_balancer_instances:
                key = '{}::{}'.format(self.region, load_balancer['LoadBalancerName'])
                elbs_from_api[key] = load_balancer

            # Process ELBs known to AWS
            for elb_identifier in elbs_from_api:
                data = elbs_from_api[elb_identifier]
                # ELB already in DB?
                if elb_identifier in elbs_from_db:
                    elb = elbs_from_db[elb_identifier]
                    if elb.update(data):
                        self.log.info(
                            'Updating info for ELB {} in {}/{}'.format(
                                elb.resource.resource_id,
                                self.account.account_name,
                                self.region
                            )
                        )
                        db.session.add(elb.resource)
                else:
                    # Not previously seen this ELB, so add it
                    if 'Tags' in data:
                        try:
                            tags = {tag['Key']: tag['Value'] for tag in data['Tags']}
                        except AttributeError:
                            tags = {}
                    else:
                        tags = {}

                    vpc_data = (data['VPCId'] if ('VPCId' in data and data['VPCId']) else 'no vpc')

                    properties = {
                        'lb_name': data['LoadBalancerName'],
                        'dns_name': data['DNSName'],
                        'instances': ' '.join(
                            [instance['InstanceId'] for instance in data['Instances']]
                        ),
                        'num_instances': len(
                            [instance['InstanceId'] for instance in data['Instances']]
                        ),
                        'vpc_id': vpc_data,
                        'state': 'not_reported'
                    }
                    if 'CanonicalHostedZoneName' in data:
                        properties['canonical_hosted_zone_name'] = data['CanonicalHostedZoneName']
                    else:
                        properties['canonical_hosted_zone_name'] = None

                    # LoadBalancerName doesn't have to be unique across all regions
                    # Use region::LoadBalancerName as resource_id
                    resource_id = '{}::{}'.format(self.region, data['LoadBalancerName'])

                    # All done, create
                    elb = ELB.create(
                        resource_id,
                        account_id=self.account.account_id,
                        location=self.region,
                        properties=properties,
                        tags=tags
                    )

                    # elbs[elb.resource.resource_id] = elb
                    self.log.info(
                        'Added new ELB {}/{}/{}'.format(
                            self.account.account_name,
                            self.region,
                            elb.resource.resource_id
                        )
                    )

            # Delete no longer existing ELBs
            elb_keys_from_db = set(list(elbs_from_db.keys()))
            self.log.debug('elb_keys_from_db =  %s', elb_keys_from_db)
            elb_keys_from_api = set(list(elbs_from_api.keys()))
            self.log.debug('elb_keys_from_api = %s', elb_keys_from_api)

            for elb_identifier in elb_keys_from_db - elb_keys_from_api:
                db.session.delete(elbs_from_db[elb_identifier].resource)
                self.log.info('Deleted ELB {}/{}/{}'.format(
                    self.account.account_name,
                    self.region,
                    elb_identifier
                )
                )
            db.session.commit()


        except:
            self.log.exception('There was a problem during ELB collection for {}/{}'.format(
                self.account.account_name,
                self.region
            ))
            db.session.rollback()
970141
def update(attributes)
      warn "[DEPRECATED] update as an instance method is deprecated. Please use CreditCard.update"
      result = @gateway.credit_card.update(token, attributes)
      if result.success?
        copy_instance_variables_from_object result.credit_card
      end
      result
    end
1343932
def get_request_quotas(self):
        

        resp = self._client.get("request-quotas")
        return [RequestQuota.from_dict(quota) for quota in resp.json()]
590428
def update(self, attributes=None):
        

        if attributes is None:
            attributes = {}

        attributes['content_type_id'] = self.sys['content_type'].id

        return super(Entry, self).update(attributes)
503626
def update_user_attributes(self, user, claims):
        

        required_fields = [field.name for field in user._meta.fields if field.blank is False]

        for field, claim in settings.CLAIM_MAPPING.items():
            if hasattr(user, field):
                if claim in claims:
                    setattr(user, field, claims[claim])
                    logger.debug("Attribute '{}' for user '{}' was set to '{}'.".format(field, user, claims[claim]))
                else:
                    if field in required_fields:
                        msg = "Claim not found in access token: '{}'. Check ADFS claims mapping."
                        raise ImproperlyConfigured(msg.format(claim))
                    else:
                        msg = "Claim '{}' for user field '{}' was not found in the access token for user '{}'. " \
                              "Field is not required and will be left empty".format(claim, field, user)
                        logger.warning(msg)
            else:
                msg = "User model has no field named '{}'. Check ADFS claims mapping."
                raise ImproperlyConfigured(msg.format(field))