Get an instance of tipo_acesso services facade.
777369
def create_tipo_acesso(self):
        """"""
        return TipoAcesso(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
612362
def get_boto_resource(
        resource,
        region=None,
        aws_access_key_id=None,
        aws_secret_access_key=None,
        aws_session_token=None,
        endpoint_url=None
        ):
    """"""
    cache_key = '{0}:{1}:{2}:{3}'.format(
        resource,
        region,
        aws_access_key_id,
        endpoint_url or ''
    )
    if not aws_session_token:
        if cache_key in RESOURCE_CACHE:
            return RESOURCE_CACHE[cache_key]
    session = get_boto_session(
        region,
        aws_access_key_id,
        aws_secret_access_key,
        aws_session_token
    )
    if not session:
        logging.error("Failed to get {0} resource.".format(resource))
        return None

    RESOURCE_CACHE[cache_key] = session.resource(
        resource,
        endpoint_url=endpoint_url
    )
    return RESOURCE_CACHE[cache_key]
610329
def endpoint_get(auth=None, **kwargs):
    '''
    
    '''
    cloud = get_operator_cloud(auth)
    kwargs = _clean_kwargs(**kwargs)
    return cloud.get_endpoint(**kwargs)
122872
def get_service_name(wrapped, instance, args, kwargs):
    """"""
    if 'serviceAbbreviation' not in instance._service_model.metadata:
        return instance._service_model.metadata['endpointPrefix']
    return instance._service_model.metadata['serviceAbbreviation']
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
269973
def get(self, service_name, **kwargs):
        """"""
        return self._send(requests.get, service_name, **kwargs)
987852
public static function getOssClient()
    {
        try {
            $ossClient = new OssClient(self::accessKeyId, self::accessKeySecret, self::endpoint, false);
        } catch (OssException $e) {
            printf(__FUNCTION__ . "creating OssClient instance: FAILED\n");
            printf($e->getMessage() . "\n");
            return null;
        }
        return $ossClient;
    }
847772
def endpoint_get(service, region=None, profile=None, interface=None, **connection_args):
    '''
    
    '''
    auth(profile, **connection_args)
    services = service_list(profile, **connection_args)
    if service not in services:
        return {'Error': 'Could not find the specified service'}
    service_id = services[service]['id']
    endpoints = endpoint_list(profile, **connection_args)

    e = [_f for _f in [e
          if e['service_id'] == service_id and
            (e['region'] == region if region else True) and
            (e['interface'] == interface if interface else True)
            else None for e in endpoints.values()] if _f]
    if len(e) > 1:
        return {'Error': 'Multiple endpoints found ({0}) for the {1} service. Please specify region.'.format(e, service)}
    if len(e) == 1:
        return e[0]
    return {'Error': 'Could not find endpoint for the specified service'}
123308
def _apicall(self, method, **params):
        """"""
        LOGGER.debug('%s(%r)', method, params)
        auth = {
            'customernumber': self._get_provider_option('auth_customer_id'),
            'apikey': self._get_provider_option('auth_api_key'),
        }
        if method == 'login':
            auth['apipassword'] = self._get_provider_option('auth_api_password')
        else:
            auth['apisessionid'] = self.api_session_id
        if not all(auth.values()):
            raise Exception('No valid authentication mechanism found')
        data = self._request('POST', url='', data={
            'action': method,
            'param': dict(params, **auth),
        })
        if data['status'] != 'success':
            raise Exception("{} ({})".format(
                data['longmessage'], data['statuscode']))
        return data.get('responsedata', {})
145101
def instance_get(plugin, opts, url_file_input, out):
    
    inst = plugin()
    hp, func, enabled_func = inst._general_init(opts, out)
    name = inst._meta.label

    kwargs = {
        'hide_progressbar': hp,
        'functionality': func,
        'enabled_functionality': enabled_func
    }

    if url_file_input:
        del kwargs['hide_progressbar']

    return {
        'inst': inst,
        'kwargs': kwargs
    }
226095
public static function getFacadeRoot() {
        $accessor = static::getFacadeAccessor();
        $instance = Application::getInstance()->make($accessor);
        if ($instance == null) {
            throw new Exception('Facade get null for: '.$accessor);
        }
        return $instance;
    }
1316737
def fromBasicServiceEndpoint(cls, endpoint):
        """"""
        type_uris = endpoint.matchTypes(cls.openid_type_uris)

        # If any Type URIs match and there is an endpoint URI
        # specified, then this is an OpenID endpoint
        if type_uris and endpoint.uri is not None:
            openid_endpoint = cls()
            openid_endpoint.parseService(
                endpoint.yadis_url,
                endpoint.uri,
                endpoint.type_uris,
                endpoint.service_element)
        else:
            openid_endpoint = None

        return openid_endpoint
338200
def create_equipamento_acesso(self):
        """"""
        return EquipamentoAcesso(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
162351
def get_service(self, service_type=None):
        """"""
        for service in self._services:
            if service.type == service_type and service_type:
                return service
        return None
416391
def _get_service_instance(host, username, password, protocol,
                          port, mechanism, principal, domain):
    '''
    
    '''
    log.trace('Retrieving new service instance')
    token = None
    if mechanism == 'userpass':
        if username is None:
            raise salt.exceptions.CommandExecutionError(
                'Login mechanism userpass was specified but the mandatory '
                'parameter \'username\' is missing')
        if password is None:
            raise salt.exceptions.CommandExecutionError(
                'Login mechanism userpass was specified but the mandatory '
                'parameter \'password\' is missing')
    elif mechanism == 'sspi':
        if principal is not None and domain is not None:
            try:
                token = get_gssapi_token(principal, host, domain)
            except Exception as exc:
                raise salt.exceptions.VMwareConnectionError(six.text_type(exc))
        else:
            err_msg = 'Login mechanism \'{0}\' was specified but the' \
                      ' mandatory parameters are missing'.format(mechanism)
            raise salt.exceptions.CommandExecutionError(err_msg)
    else:
        raise salt.exceptions.CommandExecutionError(
            'Unsupported mechanism: \'{0}\''.format(mechanism))
    try:
        log.trace('Connecting using the \'%s\' mechanism, with username \'%s\'',
                  mechanism, username)
        service_instance = SmartConnect(
            host=host,
            user=username,
            pwd=password,
            protocol=protocol,
            port=port,
            b64token=token,
            mechanism=mechanism)
    except TypeError as exc:
        if 'unexpected keyword argument' in exc.message:
            log.error('Initial connect to the VMware endpoint failed with %s', exc.message)
            log.error('This may mean that a version of PyVmomi EARLIER than 6.0.0.2016.6 is installed.')
            log.error('We recommend updating to that version or later.')
            raise
    except Exception as exc:  # pylint: disable=broad-except
        # pyVmomi's SmartConnect() actually raises Exception in some cases.
        default_msg = 'Could not connect to host \'{0}\'. ' \
                      'Please check the debug log for more information.'.format(host)

        try:
            if (isinstance(exc, vim.fault.HostConnectFault) and
                '[SSL: CERTIFICATE_VERIFY_FAILED]' in exc.msg) or \
               '[SSL: CERTIFICATE_VERIFY_FAILED]' in six.text_type(exc):
                service_instance = SmartConnect(
                    host=host,
                    user=username,
                    pwd=password,
                    protocol=protocol,
                    port=port,
                    sslContext=getattr(ssl, '_create_unverified_context', getattr(ssl, '_create_stdlib_context'))(),
                    b64token=token,
                    mechanism=mechanism)
            else:
                log.exception(exc)
                err_msg = exc.msg if hasattr(exc, 'msg') else default_msg
                raise salt.exceptions.VMwareConnectionError(err_msg)
        except Exception as exc:  # pylint: disable=broad-except
            # pyVmomi's SmartConnect() actually raises Exception in some cases.
            if 'certificate verify failed' in six.text_type(exc):
                context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
                context.verify_mode = ssl.CERT_NONE
                try:
                    service_instance = SmartConnect(
                        host=host,
                        user=username,
                        pwd=password,
                        protocol=protocol,
                        port=port,
                        sslContext=context,
                        b64token=token,
                        mechanism=mechanism
                    )
                except Exception as exc:
                    log.exception(exc)
                    err_msg = exc.msg if hasattr(exc, 'msg') else six.text_type(exc)
                    raise salt.exceptions.VMwareConnectionError(
                        'Could not connect to host \'{0}\': '
                        '{1}'.format(host, err_msg))
            else:
                err_msg = exc.msg if hasattr(exc, 'msg') else default_msg
                log.trace(exc)
                raise salt.exceptions.VMwareConnectionError(err_msg)
    atexit.register(Disconnect, service_instance)
    return service_instance
691615
protected function getOauthMiddleware()
    {
        if (!$this->oauthMiddleware) {
            if (!$this->isLoggedIn()) {
                throw new \RuntimeException('Not logged in');
            }

            $grant = new ClientCredentials();
            $grantOptions = [];

            // Set up the "exchange" (normal) API token type.
            if ($this->config['api_token'] && $this->config['api_token_type'] !== 'access') {
                $grant = new ApiToken();
                $grantOptions['api_token'] = $this->config['api_token'];
            }

            $this->oauthMiddleware = new GuzzleMiddleware($this->getProvider(), $grant, $grantOptions);
            $this->oauthMiddleware->setTokenSaveCallback(function (AccessToken $token) {
                $this->saveToken($token);
            });

            // If an access token is already available (via an API token or via
            // the session) then set it in the middleware in advance.
            if ($accessToken = $this->loadToken()) {
                $this->oauthMiddleware->setAccessToken($accessToken);
            }
        }

        return $this->oauthMiddleware;
    }
651250
def _get_instance(self, **kwargs):
        """"""
        current_app.logger.info("Getting instance")
        current_app.logger.debug("kwargs: {}".format(kwargs))

        current_app.logger.info(
            "Loading instance: {}".format(kwargs['obj_id']))
        rec = self.db_query.get_instance(self.db_collection, kwargs['obj_id'])
        g._resource_instance = rec
        current_app.logger.debug(
            "g._resource_instance: {}".format(g._resource_instance))
        return rec