Return instance of resource management client.
168122
def _get_management_client(self, client_class):
        
        try:
            client = get_client_from_auth_file(
                client_class, auth_path=self.service_account_file
            )
        except ValueError as error:
            raise AzureCloudException(
                'Service account file format is invalid: {0}.'.format(error)
            )
        except KeyError as error:
            raise AzureCloudException(
                'Service account file missing key: {0}.'.format(error)
            )
        except Exception as error:
            raise AzureCloudException(
                'Unable to create resource management client: '
                '{0}.'.format(error)
            )

        return client
733420
def _get_instance(self):
        """"""
        resource = self._connect()

        try:
            instance = resource.Instance(self.running_instance_id)
        except Exception:
            raise EC2CloudException(
                'Instance with ID: {instance_id} not found.'.format(
                    instance_id=self.running_instance_id
                )
            )
        return instance
427167
def get_instance(cls, state):
        """"""
        if cls.instance is None:
            cls.instance = UserStorageHandler(state)
        return cls.instance
1228950
def _build_client(self, name=None):
        
        url_path = self._url_path + [name] if name else self._url_path
        return Client(host=self.host,
                      version=self._version,
                      request_headers=self.request_headers,
                      url_path=url_path,
                      append_slash=self.append_slash,
                      timeout=self.timeout)
544747
def get_resources(cls):
        """"""
        my_plurals = resource_helper.build_plural_mappings(
            {}, RESOURCE_ATTRIBUTE_MAP)
        attributes.PLURALS.update(my_plurals)
        attr_map = RESOURCE_ATTRIBUTE_MAP
        resources = resource_helper.build_resource_info(my_plurals,
                                                        attr_map,
                                                        constants.A10_DEVICE_INSTANCE)

        return resources
35980
def get_client(provider, token=''):
    ""
    cls = OAuth2Client
    if provider.request_token_url:
        cls = OAuthClient
    return cls(provider, token)
332342
def get_instance():
    """"""
    global _instances
    user_agents = _config['user-agents']

    user_agent = user_agents[
        random.randint(0, len(user_agents) - 1)
    ] if len(user_agents) > 0 else DEFAULT_UA

    instance_key = user_agent

    try:
        instance = _instances[instance_key]
    except KeyError:
        instance = Client(user_agent, get_proxy)
        _instances[instance_key] = instance

    return instance
703990
def get_client(self, provider):
        ""
        if self.client_class is not None:
            return self.client_class(provider)
        return get_client(provider)
1068620
def resource(self, *resources):
        
        resources = tuple(self.resources) + resources
        return Resource(self.client, resources)
1009046
def client(self):
        """"""
        if isinstance(self._client, six.string_types):
            self._client = Client(self._client, self)

        return self._client
372154
def get(self, request, **resources):
        

        instance = resources.get(self._meta.name)
        if not instance is None:
            return instance

        return self.paginate(
            request, self.get_collection(request, **resources))
179188
def get_client(site=None):
    """"""
    if 'CITRINATION_API_KEY' not in environ:
        raise ValueError("'CITRINATION_API_KEY' is not set as an environment variable")
    if not site:
        site = environ.get("CITRINATION_SITE", "https://citrination.com")
    return CitrinationClient(environ['CITRINATION_API_KEY'], site)
727417
def get_resource_manager(self, resource_type, data=None):
        
        if '.' in resource_type:
            provider_name, resource_type = resource_type.split('.', 1)
        else:
            provider_name = self.ctx.policy.provider_name

        provider_resources = clouds[provider_name].resources
        klass = provider_resources.get(resource_type)
        if klass is None:
            raise ValueError(resource_type)

        # if we're already querying via config carry it forward
        if not data and self.source_type == 'config' and getattr(
                klass.get_model(), 'config_type', None):
            return klass(self.ctx, {'source': self.source_type})
        return klass(self.ctx, data or {})
164603
def get_instance(self):
        
        return Instance(self.rest_client.make_request(self.instance), self.rest_client)
1366860
def basic_client():
    """"""
    es_connected = False
    while not es_connected:
        try:
            ES = Elasticsearch(
                hosts=[HOSTNAME]
            )
            es_connected = True
        except TransportError as e:
            logging.info('Not yet connected: %s, sleeping for 1s', e)
            time.sleep(1)
    return ES
43021
def get_client(self, request=None):
        """"""

        if not isinstance(request, oauth.Request):
            request = self.get_oauth_request()
        client_key = request.get_parameter('oauth_consumer_key')
        if not client_key:
            raise Exception('Missing "oauth_consumer_key" parameter in ' \
                'OAuth "Authorization" header')

        client = models.Client.get_by_key_name(client_key)
        if not client:
            raise Exception('Client "%s" not found.' % client_key)

        return client
728294
def client(self):
        
        if self._client is not None:
            return self._client

        self._client = self.get_client()
        return self._client