Get a list of accounts where a service has been enabled.
161898
def get_service_enabled(self, name, accounts_list=None, search_filter=None, region=None):
        """"""
        if not accounts_list:
            accounts = self.get_all(search_filter=search_filter)
        else:
            accounts = accounts_list

        if self.version == 1:
            accounts = accounts['accounts']

        enabled = []
        for account in accounts:
            if self.version == 1:
                account_filter = "accounts[?id=='{id}']".format(id=account['id'])
            else:
                account_filter = "[?id=='{id}']".format(id=account['id'])

            service = self.get_service(name, search_filter=account_filter)

            if self.version == 1:
                if service:
                    service = service['enabled']  # no region information available in v1
            else:
                if not region:
                    service_filter = "status[?enabled]"
                else:
                    service_filter = "status[?(region=='{region}' || region=='all') && enabled]".format(region=region)

                service = jmespath.search(service_filter, service)

            if service:
                enabled.append(account)

        return enabled
279007
def get_account_details(self):
        
        headers = self._manager.get_account_headers()
        acct_prefix = "x-account-"
        meta_prefix = ACCOUNT_META_PREFIX.lower()
        ret = {}
        for hkey, hval in list(headers.items()):
            lowkey = hkey.lower()
            if lowkey.startswith(acct_prefix):
                if not lowkey.startswith(meta_prefix):
                    cleaned = hkey.replace(acct_prefix, "").replace("-", "_")
                    try:
                        # Most values are ints
                        ret[cleaned] = int(hval)
                    except ValueError:
                        ret[cleaned] = hval
        return ret
843446
def services(self):
        """"""
        ids = [ref['id'] for ref in self['services']]
        return [Service.fetch(id) for id in ids]
802391
def GetAccounts(alias=None):
		""""""
		if alias is not None:  payload = {'AccountAlias': alias}
		else:  payload = {}
		r = clc.v1.API.Call('post','Account/GetAccounts',payload)
		if int(r['StatusCode']) == 0:  
			# Assume first response is always the original account.  Not sure if this is reliable
			if not clc.ALIAS:  clc.ALIAS = r['Accounts'][0]['AccountAlias']
			if not clc.LOCATION:  clc.LOCATION = r['Accounts'][0]['Location']

			return(r['Accounts'])
469988
def get_for_accounts(self, accounts: List[Account]):
        '''  '''
        account_ids = [acc.guid for acc in accounts]
        query = (
            self.query
            .filter(Split.account_guid.in_(account_ids))
        )
        splits = query.all()
        return splits
1324595
def service_list(auth=None, **kwargs):
    '''
    
    '''
    cloud = get_operator_cloud(auth)
    kwargs = _clean_kwargs(**kwargs)
    return cloud.list_services(**kwargs)
175065
def list(self, request, *args, **kwargs):
        
        return super(ServicesViewSet, self).list(request, *args, **kwargs)
718669
def get_services(profile='pagerduty', subdomain=None, api_key=None):
    '''
    
    '''

    return _list_items(
        'services',
        'id',
        profile=profile,
        subdomain=subdomain,
        api_key=api_key,
    )
764519
def get_enabled():
    '''
    
    '''
    ret = set()
    for name in _iter_service_names():
        if _service_is_upstart(name):
            if _upstart_is_enabled(name):
                ret.add(name)
        else:
            if _service_is_sysv(name):
                if _sysv_is_enabled(name):
                    ret.add(name)
    return sorted(ret)
688030
def service_addresses(service, index = nil)
      loop do
        addresses, nindex = service_addresses!(service, index)
        return [addresses, nindex] if addresses && nindex
      end
    end
1283846
def get_holding_accounts(self) -> List[Account]:
        
        if not self.__holding_accounts:
            self.__holding_accounts = self.__get_holding_accounts_query().all()

        return self.__holding_accounts
152992
def get_accounts(self, **params):
        """"""
        response = self._get('v2', 'accounts', params=params)
        return self._make_api_object(response, Account)
96968
def _GetGsScopes(self):
    """"""
    service_accounts = self.watcher.GetMetadata(metadata_key=self.metadata_key)
    try:
      scopes = service_accounts[self.service_account]['scopes']
      return list(GS_SCOPES.intersection(set(scopes))) if scopes else None
    except KeyError:
      return None
1295541
def list_capability_definitions(service_instance=None):
    '''
    
    '''
    profile_manager = salt.utils.pbm.get_profile_manager(service_instance)
    ret_list = [_get_capability_definition_dict(c) for c in
                salt.utils.pbm.get_capability_definitions(profile_manager)]
    return ret_list
688827
def get_subscribed_services_names(cls):
        
        # This is very inefficient - loops within loops within loops, and
        # many network requests
        # Optimise it?
        accounts_for_service = Account.get_accounts_for_service
        service_data = cls._get_music_services_data().values()
        return [
            service['Name'] for service in service_data
            if len(
                accounts_for_service(service['ServiceType'])
            ) > 0
        ]
1097945
def list(ctx):
    """"""
    if ctx.namespace != 'accounts':
        click.echo(
            click.style('Only account data is available for listing.', fg='red')
        )
        return

    swag = create_swag_from_ctx(ctx)
    accounts = swag.get_all()
    _table = [[result['name'], result.get('id')] for result in accounts]
    click.echo(
        tabulate(_table, headers=["Account Name", "Account Number"])
    )
143601
def get_account_service(self):
        """"""
        account_service_url = utils.get_subresource_path_by(self,
                                                            'AccountService')

        return (account_service.
                HPEAccountService(self._conn, account_service_url,
                                  redfish_version=self.redfish_version))