How to use the ask-sdk-model.ask_sdk_model.services.base_service_client.BaseServiceClient function in ask-sdk-model

To help you get started, we’ve selected a few ask-sdk-model examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alexa / alexa-apis-for-python / ask-sdk-model / ask_sdk_model / services / base_service_client.py View on Github external
in {} braces
        :type path: str
        :param query_params: Query Parameters to be appended to the url
        :type query_params: list(tuple(str, str)
        :param path_params: Parameters to be interpolated in the path.
            Keys should match variables specified in the path # noqa: E501
        :type path_params: dict(str, str)
        :return Built url
        :rtype: str
        """
        process_endpoint = (
            endpoint[:-1] if endpoint.endswith("/") else endpoint)
        path_with_params = BaseServiceClient.__interpolate_params(path,
                                                                  path_params)
        is_constant_query_present = "?" in path_with_params
        query_string = BaseServiceClient.__build_query_string(
            query_params, is_constant_query_present)

        return '{}{}{}'.format(process_endpoint, path_with_params,
                               query_string)
github alexa / alexa-apis-for-python / ask-sdk-model / ask_sdk_model / services / base_service_client.py View on Github external
:param endpoint: Endpoint to be sending the api call
        :type endpoint: str
        :param path: Path to send the api call. Could contain variables
            in {} braces
        :type path: str
        :param query_params: Query Parameters to be appended to the url
        :type query_params: list(tuple(str, str)
        :param path_params: Parameters to be interpolated in the path.
            Keys should match variables specified in the path # noqa: E501
        :type path_params: dict(str, str)
        :return Built url
        :rtype: str
        """
        process_endpoint = (
            endpoint[:-1] if endpoint.endswith("/") else endpoint)
        path_with_params = BaseServiceClient.__interpolate_params(path,
                                                                  path_params)
        is_constant_query_present = "?" in path_with_params
        query_string = BaseServiceClient.__build_query_string(
            query_params, is_constant_query_present)

        return '{}{}{}'.format(process_endpoint, path_with_params,
                               query_string)
github alexa / alexa-apis-for-python / ask-sdk-model / ask_sdk_model / services / lwa / lwa_client.py View on Github external
from dateutil import tz
from datetime import datetime, timedelta
from ..base_service_client import BaseServiceClient
from ..service_client_response import ServiceClientResponse
from .access_token_request import AccessTokenRequest
from .access_token import AccessToken

if typing.TYPE_CHECKING:
    from .access_token_response import AccessTokenResponse
    from ..api_configuration import ApiConfiguration
    from ..authentication_configuration import AuthenticationConfiguration
    from typing import Any, Dict, List, Optional


class LwaClient(BaseServiceClient):
    """Client to call Login with Amazon (LWA) to retrieve access tokens.

    :param api_configuration: ApiConfiguration instance with valid
        Serializer and ApiClient. The authorization value and api endpoint
        is not used by the LWA Client.
    :type api_configuration:
        ask_sdk_model.services.api_configuration.ApiConfiguration
    :param authentication_configuration: AuthenticationConfiguration
        instance with valid client id and client secret, for making LWA
        calls.
    :type authentication_configuration: ask_sdk_model.services.authentication_configuration.AuthenticationConfiguration
    :param grant_type: The grant type which is used to make the HTTP request.
    :type grant_type: (optional) str
    :raises: :py:class:`ValueError` if authentication configuration is not
        provided.
    """
github alexa / alexa-apis-for-python / ask-sdk-model / ask_sdk_model / services / base_service_client.py View on Github external
if body:
            request.body = self._serializer.serialize(body)

        try:
            response = self._api_client.invoke(request)
        except Exception as e:
            raise ServiceException(
                message="Call to service failed: {}".format(str(e)),
                status_code=500, headers=None, body=None)

        if response.status_code is None:
            raise ServiceException(message="Invalid Response, no status code",
                                   status_code=500, headers=None, body=None)

        if BaseServiceClient.__is_code_successful(response.status_code):
            api_response = ApiResponse(headers=response.headers,
                                       status_code=response.status_code)

            # Body of HTTP 204 (No Content) response should be empty, return
            # ApiResponse with empty body, since body is not a valid json
            # value to be deserialized
            if ((response_type is None) or (
                    response.status_code == 204 and not response.body)):
                return api_response

            api_response.body = self._serializer.deserialize(
                payload=response.body, obj_type=response_type)
            return api_response

        if response_definitions:
            exception_metadata_list = ([d for d in response_definitions if
github alexa / alexa-apis-for-python / ask-sdk-model / ask_sdk_model / services / base_service_client.py View on Github external
:type path_params: dict(str, str)
        :param response_definitions: Well-known expected responses by
            the ServiceClient
        :type response_definitions: list(ask_sdk_model.services.service_client_response.ServiceClientResponse)
        :param body: Request body
        :type body: object
        :param response_type: Type of the expected response if applicable
        :type response_type: class
        :return: ApiResponse object.
        :rtype: :py:class:`ask_sdk_model.services.api_response.py`
        :raises: :py:class:`ask_sdk_model.services.service_exception.ServiceException`
            if service fails and :py:class:`ValueError` if serializer or API
            Client is not configured in api_configuration # noqa: E501
        """
        request = ApiClientRequest()
        request.url = BaseServiceClient.__build_url(endpoint=endpoint,
                                                    path=path,
                                                    query_params=query_params,
                                                    path_params=path_params)
        request.method = method
        request.headers = header_params

        if self._serializer is None:
            raise ValueError("Serializer is None")

        if self._api_client is None:
            raise ValueError("API client is None")

        if body:
            request.body = self._serializer.serialize(body)

        try:

ask-sdk-model

The ASK SDK Model package provides model definitions, for building Alexa Skills.

Apache-2.0
Latest version published 1 year ago

Package Health Score

56 / 100
Full package analysis

Popular ask-sdk-model functions

Similar packages