Return a service endpoint for interacting with a Google API.
359127
def build_service(name=None, **kwargs):
    """"""
    if name is not None:
        for kw, value in iteritems(SERVICES[name]):
            kwargs.setdefault(kw, value)
    return apiclient.discovery.build(**kwargs)
69006
def _get_api_url(self, secure=None, **formatters):
        '''
        '''
        if self.endpoint is None:
            raise NotImplementedError('endpoint must be defined on a subclass')
        if secure is None:
            secure = self.secure
        if secure:
            api_url = POSTMARK_API_URL_SECURE
        else:
            api_url = POSTMARK_API_URL
        url = urljoin(api_url, self.endpoint)
        if formatters:
            url = url.format(**formatters)
        return url
1167200
public Response get(String endpoint) {
        return call(Method.GET, endpoint, null, null);
    }
1362272
def _configure_endpoint(self, endpoint):
        """"""
        if not endpoint.startswith('http'):
            endpoint = 'https://' + endpoint
        if not endpoint.endswith('/'):
            endpoint += '/'
        return endpoint
1330440
def endpoint(url, method="GET", expected_status=200):
    
    def dec(obj):
        obj.ENDPOINT = url
        obj.METHOD = method
        obj.EXPECTED_STATUS = expected_status
        return obj

    return dec
1080621
def get_api_service(self, name=None):
        """"""
        try:
            svc = self.services_by_name.get(name, None)
            if svc is None:
                raise ValueError(f"Couldn't find the API service configuration")
            return svc
        except:  # NOQA
            raise Exception(f"Failed to retrieve the API service configuration")
286409
def endpoint_class(collection):
    
    with app.app_context():
        try:
            cls = current_app.class_references[collection]
        except KeyError:
            raise InvalidAPIUsage(404)
        return cls
1254561
def get(self, endpoint: str, **kwargs) -> dict:
        """"""

        return self._request('GET', endpoint, **kwargs)
650003
def post(self, endpoint: str, **kwargs) -> dict:
        """"""

        return self._request('POST', endpoint, **kwargs)
635450
def api_call(self, opts, args=None, body=None, **kwargs):
        """"""
        if args:
            path = opts['name'] % args
        else:
            path = opts['name']
        path = '/api/v1%s' % path
        return self._request(
            opts['method'], path=path, payload=body, **kwargs)
698669
async def api(self, endpoint, params=None, test=False):
        """"""
        data = {}
        url = "{}/{}".format(self._api, endpoint)
        try:
            async with async_timeout.timeout(8, loop=self._loop):
                response = await self._session.get(
                    url, auth=self._auth, headers=HEADERS, params=params
                )

            if response.status == 200:
                self._authenticated = True
                self._connected = True
                if not test:
                    data = await response.json()
            elif response.status == 401:
                self._authenticated = False
                self._connected = True

        except asyncio.TimeoutError as error:
            self._authenticated, self._connected = False, False
            if not test:
                _LOGGER.warning("Timeouterror connecting to Traccar, %s", error)
        except aiohttp.ClientError as error:
            self._authenticated, self._connected = False, False
            if not test:
                _LOGGER.warning("Error connecting to Traccar, %s", error)
        except socket.gaierror as error:
            self._authenticated, self._connected = False, False
            if not test:
                _LOGGER.warning("Error connecting to Traccar, %s", error)
        except TypeError as error:
            self._authenticated, self._connected = False, False
            if not test:
                _LOGGER.warning("Error connecting to Traccar, %s", error)
        except Exception as error:  # pylint: disable=broad-except
            self._authenticated, self._connected = False, False
            if not test:
                _LOGGER.warning("Error connecting to Traccar, %s", error)

        return data
88218
def get_endpoint(self):
        
        try:
            _iss = self.service_context.issuer
        except AttributeError:
            _iss = self.endpoint

        if _iss.endswith('/'):
            return OIDCONF_PATTERN.format(_iss[:-1])
        else:
            return OIDCONF_PATTERN.format(_iss)
1123613
def endpoint_search(auth=None, **kwargs):
    '''
    
    '''
    cloud = get_operator_cloud(auth)
    kwargs = _clean_kwargs(**kwargs)
    return cloud.search_endpoints(**kwargs)
256443
def get(url, parameters = {}, skip_status_check = false)
      response = connection.get("#{api_endpoint}#{url}", parameters)
      on_complete(response) unless skip_status_check
      response
    end
544475
def _get_response(self, endpoint, query, is_post=False):
        """"""
        timeout_secs = self._settings.get('timeout', 10)
        headers = self._settings.get('request_headers', {})
        try:
            if is_post:
                response = requests.post(
                    endpoint, data=query, headers=headers, timeout=timeout_secs)
            else:
                response = requests.get(
                    endpoint, params=query, headers=headers, timeout=timeout_secs)
        except requests.exceptions.Timeout as e:
            raise Exception(
                'API request timed out after %s seconds.' % timeout_secs)
        except Exception as e:
            raise e

        if response.status_code != 200:
            raise Exception('Received status code %s from %s. Content is:\n%s'
                            % (response.status_code,
                               self.get_service_name(),
                               response.text))
        return response
384474
def get_endpoint(cls):
        
        if cls.endpoint is not None:
            return cls.endpoint
        s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', cls.__name__)
        return cls.sanitize_ep(
            re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower(),
            plural=True
        )
375385
def service_get(auth=None, **kwargs):
    '''
    
    '''
    cloud = get_operator_cloud(auth)
    kwargs = _clean_kwargs(**kwargs)
    return cloud.get_service(**kwargs)