A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://alexa-skills-kit-python-sdk.readthedocs.io/en/latest/api/runtime.html below:

Runtime — Alexa Skills Kit SDK for Python 1.13.0 documentation

Alexa Skills Kit SDK for Python Runtime¶ Request Dispatch Components¶ Abstract Classes¶
class ask_sdk_runtime.dispatch.AbstractRequestDispatcher¶

Bases: object

Dispatcher which handles dispatching input request to the corresponding handler.

User needs to implement the dispatch method, to handle the processing of the incoming request in the handler input. A response may be expected out of the dispatch method.

dispatch(handler_input)¶

Dispatches an incoming request to the appropriate request handler and returns the output.

Parameters: handler_input (Input) – generic input to the dispatcher Returns: generic output returned by handler in the dispatcher Return type: Union[None, Output]
class ask_sdk_runtime.dispatch_components.request_components.AbstractRequestHandler¶

Bases: typing.Generic

Request Handlers are responsible for processing dispatch inputs and generating output.

Custom request handlers needs to implement can_handle and handle methods. can_handle returns True if the handler can handle the current input. handle processes the input and may return a output.

can_handle(handler_input)¶

Returns true if Request Handler can handle the dispatch input.

Parameters: handler_input (Input) – Generic input passed to the dispatcher. Returns: Boolean value that tells the dispatcher if the current input can be handled by this handler. Return type: bool
handle(handler_input)¶

Handles the dispatch input and provides an output for dispatcher to return.

Parameters: handler_input (Input) – Generic input passed to the dispatcher. Returns: Generic Output for the dispatcher to return or None Return type: Union[Output, None]
class ask_sdk_runtime.dispatch_components.request_components.AbstractRequestInterceptor¶

Bases: typing.Generic

Interceptor that runs before the handler is called.

The process method has to be implemented, to run custom logic on the input, before it is handled by the Handler.

process(handler_input)¶

Process the input before the Handler is run.

Parameters: handler_input (Input) – Generic input passed to the dispatcher. Return type: None
class ask_sdk_runtime.dispatch_components.request_components.AbstractResponseInterceptor¶

Bases: typing.Generic

Interceptor that runs after the handler is called.

The process method has to be implemented, to run custom logic on the input and the dispatch output generated after the handler is executed on the input.

process(handler_input, response)¶

Process the input and the output after the Handler is run.

Parameters:
  • handler_input (Input) – Generic input passed to the dispatcher.
  • response (Union[None, Output]) – Execution result of the Handler on dispatch input.
Return type:

None

class ask_sdk_runtime.dispatch_components.request_components.AbstractRequestHandlerChain¶

Bases: object

Abstract class containing Request Handler and corresponding Interceptors.

request_handler()¶
Returns: Registered Request Handler instance. Return type: object
request_interceptors()¶
response_interceptors()¶
class ask_sdk_runtime.dispatch_components.request_components.AbstractRequestMapper¶

Bases: object

Class for request routing to the appropriate handler chain.

User needs to implement get_request_handler_chain method, to provide a routing mechanism of the input to the appropriate request handler chain containing the handler and the interceptors.

get_request_handler_chain(handler_input)¶

Get the handler chain that can process the handler input.

Parameters: handler_input (Input) – Generic input passed to the dispatcher. Returns: Handler Chain that can handle the request under dispatch input. Return type: AbstractRequestHandlerChain
class ask_sdk_runtime.dispatch_components.request_components.AbstractHandlerAdapter¶

Bases: object

Abstracts handling of a request for specific handler types.

supports(handler)¶

Returns true if adapter supports the handler.

This method checks if the adapter supports the handler execution. This is usually checked by the type of the handler.

Parameters: handler (object) – Request Handler instance. Returns: Boolean denoting whether the adapter supports the handler. Return type: bool
execute(handler_input, handler)¶

Executes the handler with the provided dispatch input.

Parameters:
  • handler_input (Input) – Generic input passed to the dispatcher.
  • handler (object) – Request Handler instance.
Returns:

Result executed by passing handler_input to handler.

Return type:

Union[None, Output]

class ask_sdk_runtime.dispatch_components.exception_components.AbstractExceptionHandler¶

Bases: typing.Generic

Handles exception types and optionally produce an output.

The abstract class is similar to Request Handler, with methods can_handle and handle. The can_handle method checks if the handler can support the input and the exception. The handle method processes the input and exception, to optionally produce an output.

can_handle(handler_input, exception)¶

Checks if the handler can support the exception raised during dispatch.

Parameters:
  • handler_input (Input) – Generic input passed to the dispatcher.
  • exception (Exception) – Exception raised during dispatch.
Returns:

Boolean whether handler can handle exception or not.

Return type:

bool

handle(handler_input, exception)¶

Process the dispatch input and exception.

Parameters:
  • handler_input (Input) – Generic input passed to the dispatcher.
  • exception (Exception) – Exception raised during dispatch.
Returns:

Optional output object to serve as dispatch return.

Return type:

Union[None, Output]

class ask_sdk_runtime.dispatch_components.exception_components.AbstractExceptionMapper¶

Bases: typing.Generic

Mapper to register custom Exception Handler instances.

The exception mapper is used by ask_sdk_runtime.dispatch.GenericRequestDispatcher dispatch method, to handle exceptions. The mapper can contain one or more exception handlers. Handlers are accessed through the mapper to attempt to find a handler that is compatible with the current exception.

get_handler(handler_input, exception)¶

Returns a suitable exception handler to dispatch the specified exception, if one exists.

Implementations¶
class ask_sdk_runtime.dispatch.GenericRequestDispatcher(options)¶

Bases: ask_sdk_runtime.dispatch.AbstractRequestDispatcher

Generic implementation of AbstractRequestDispatcher.

The runtime configuration contains the components required for the dispatcher, which is passed during initialization.

When the dispatch method is invoked, using a list of ask_sdk_runtime.dispatch_components.request_components.RequestMapper , the Dispatcher finds a handler for the request and delegates the invocation to the supported ask_sdk_runtime.dispatch_components.request_components.HandlerAdapter . If the handler raises any exception, it is delegated to ask_sdk_runtime.dispatch_components.exception_components.ExceptionMapper to handle or raise it to the upper stack.

dispatch(handler_input)¶

Dispatches an incoming request to the appropriate request handler and returns the output.

Before running the request on the appropriate request handler, dispatcher runs any predefined global request interceptors. On successful response returned from request handler, dispatcher runs predefined global response interceptors, before returning the response.

class ask_sdk_runtime.dispatch_components.request_components.GenericRequestHandlerChain(request_handler, request_interceptors=None, response_interceptors=None)¶

Bases: ask_sdk_runtime.dispatch_components.request_components.AbstractRequestHandlerChain

Generic implementation of AbstractRequestHandlerChain.

Generic Request Handler Chain accepts request handler of any type.

request_handler¶
Returns: Registered Request Handler instance. Return type: object
request_interceptors¶
response_interceptors¶
add_request_interceptor(interceptor)¶

Add interceptor to Request Interceptors list.

add_response_interceptor(interceptor)¶

Add interceptor to Response Interceptors list.

class ask_sdk_runtime.dispatch_components.request_components.GenericRequestMapper(request_handler_chains)¶

Bases: ask_sdk_runtime.dispatch_components.request_components.AbstractRequestMapper

Implementation of AbstractRequestMapper that registers RequestHandlerChain.

The class accepts request handler chains of type GenericRequestHandlerChain only. The get_request_handler_chain method returns the GenericRequestHandlerChain instance that can handle the request in the handler input.

request_handler_chains¶
add_request_handler_chain(request_handler_chain)¶

Checks the type before adding it to the request_handler_chains instance variable.

get_request_handler_chain(handler_input)¶

Get the request handler chain that can handle the dispatch input.

Parameters: handler_input (Input) – Generic input passed to the dispatcher. Returns: Handler Chain that can handle the input. Return type: Union[None, GenericRequestHandlerChain]
class ask_sdk_runtime.dispatch_components.request_components.GenericHandlerAdapter¶

Bases: ask_sdk_runtime.dispatch_components.request_components.AbstractHandlerAdapter

GenericHandler Adapter for handlers of type ask_sdk_runtime.dispatch_components.request_components.AbstractRequestHandler.

supports(handler)¶

Returns true if handler is ask_sdk_runtime.dispatch_components.request_components.AbstractRequestHandler instance.

execute(handler_input, handler)¶

Executes the handler with the provided handler input.

Parameters:
  • handler_input (Input) – Generic input passed to the dispatcher.
  • handler (object) – Request Handler instance.
Returns:

Result executed by passing handler_input to handler.

Return type:

Union[None, Output]

class ask_sdk_runtime.dispatch_components.exception_components.GenericExceptionMapper(exception_handlers)¶

Bases: ask_sdk_runtime.dispatch_components.exception_components.AbstractExceptionMapper

Generic Implementation of exception mapper, to register AbstractExceptionHandler instances.

The class accepts exception handlers of type AbstractExceptionHandler only. The get_handler method returns the AbstractExceptionHandler instance that can handle the dispatch input and the exception raised from the dispatch method.

exception_handlers¶
add_exception_handler(exception_handler)¶

Checks the type before adding it to the exception_handlers instance variable.

get_handler(handler_input, exception)¶

Get the exception handler that can handle the input and exception.

Skill Components¶
class ask_sdk_runtime.skill.RuntimeConfiguration(request_mappers, handler_adapters, request_interceptors=None, response_interceptors=None, exception_mapper=None, loaders=None, renderer=None)¶

Bases: object

Configuration Object that represents standard components needed to build the dispatcher in the AbstractSkill.

class ask_sdk_runtime.skill.RuntimeConfigurationBuilder¶

Bases: object

Builder class for creating a runtime configuration object, from base dispatch components.

add_request_handler(request_handler)¶

Register input to the request handlers list.

Parameters: request_handler (AbstractRequestHandler) – Request Handler instance to be registered. Returns: None
add_request_handlers(request_handlers)¶

Register input to the request handlers list.

add_exception_handler(exception_handler)¶

Register input to the exception handlers list.

add_global_request_interceptor(request_interceptor)¶

Register input to the global request interceptors list.

add_global_response_interceptor(response_interceptor)¶

Register input to the global response interceptors list.

add_loader(loader)¶

Register input to the loaders list.

Parameters: loader (ask_sdk_runtime.view_resolvers.AbstractTemplateLoader) – Loader to load the template
add_loaders(loaders)¶

Register input to the loaders list.

Parameters: loaders (ask_sdk_runtime.view_resolvers.AbstractTemplateLoader) – List of loaders
add_renderer(renderer)¶

Register input to the renderer.

Parameters: renderer (ask_sdk_runtime.view_resolvers.AbstractTemplateRenderer) – Renderer to render the template
get_runtime_configuration()¶

Build the runtime configuration object from the registered components.

class ask_sdk_runtime.skill.AbstractSkill¶

Bases: typing.Generic

Abstract class that acts as entry level container for skill invocation.

Domain SDKs should implement the supports and invoke methods.

supports(event, context)¶

Check if the skill supports the corresponding input.

Parameters:
  • event (SkillInput) – input instance containing request information.
  • context (Any) – Context passed during invocation
Returns:

boolean if this type of request can be handled by this skill.

Return type:

bool

invoke(event, context)¶

Invokes the dispatcher, to handle the skill input and return a skill output.

Parameters:
  • event (SkillInput) – input instance containing request information.
  • context (Any) – Context passed during invocation
Returns:

output generated by handling the request.

Return type:

SkillOutput

class ask_sdk_runtime.skill_builder.AbstractSkillBuilder¶

Bases: object

Abstract Skill Builder with helper functions for building ask_sdk_runtime.skill.AbstractSkill object.

Domain SDKs has to implement the create method that returns an instance of the skill implementation for the domain type.

add_request_handler(request_handler)¶

Register input to the request handlers list.

add_exception_handler(exception_handler)¶

Register input to the exception handlers list.

Parameters: exception_handler (ask_sdk_runtime.dispatch_components.request_components.AbstractExceptionHandler) – Exception Handler instance to be registered. Returns: None
add_global_request_interceptor(request_interceptor)¶

Register input to the global request interceptors list.

add_global_response_interceptor(response_interceptor)¶

Register input to the global response interceptors list.

add_loaders(loaders)¶

Register input to the loaders list.

Parameters: loaders (ask_sdk_runtime.view_resolvers.AbstractTemplateLoader) – List of loaders
add_loader(loader)¶

Register input to loaders list.

Parameters: loader (ask_sdk_runtime.view_resolvers.AbstractTemplateLoader) – Loader to load template from a specific data source
add_renderer(renderer)¶

Register renderer to generate template responses.

Parameters: renderer (ask_sdk_runtime.view_resolvers.AbstractTemplateRenderer) – Renderer to render the template
request_handler(can_handle_func)¶

Decorator that can be used to add request handlers easily to the builder.

The can_handle_func has to be a Callable instance, which takes a single parameter and no varargs or kwargs. This is because of the RequestHandler class signature restrictions. The returned wrapper function can be applied as a decorator on any function that returns a response object by the skill. The function should follow the signature of the handle function in ask_sdk_runtime.dispatch_components.request_components.AbstractRequestHandler class.

Parameters: can_handle_func (Callable[[Input], bool]) – The function that validates if the request can be handled. Returns: Wrapper function that can be decorated on a handle function.
exception_handler(can_handle_func)¶

Decorator that can be used to add exception handlers easily to the builder.

The can_handle_func has to be a Callable instance, which takes two parameters and no varargs or kwargs. This is because of the ExceptionHandler class signature restrictions. The returned wrapper function can be applied as a decorator on any function that processes the exception raised during dispatcher and returns a response object by the skill. The function should follow the signature of the handle function in ask_sdk_runtime.dispatch_components.exception_components.AbstractExceptionHandler class.

Parameters: can_handle_func (Callable[[Input, Exception], bool]) – The function that validates if the exception can be handled. Returns: Wrapper function that can be decorated on a handle function.
global_request_interceptor()¶

Decorator that can be used to add global request interceptors easily to the builder.

The returned wrapper function can be applied as a decorator on any function that processes the input. The function should follow the signature of the process function in ask_sdk_runtime.dispatch_components.request_components.AbstractRequestInterceptor class.

Returns: Wrapper function that can be decorated on a interceptor process function.
global_response_interceptor()¶

Decorator that can be used to add global response interceptors easily to the builder.

The returned wrapper function can be applied as a decorator on any function that processes the input and the response generated by the request handler. The function should follow the signature of the process function in ask_sdk_runtime.dispatch_components.request_components.AbstractResponseInterceptor class.

Returns: Wrapper function that can be decorated on a interceptor process function.
create()¶

Create a skill object using the registered components.

Returns: a skill object that can be used for invocation. Return type: AbstractSkill

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4