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]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: boolhandle
(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]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: Noneask_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.
ask_sdk_runtime.dispatch_components.request_components.
AbstractRequestHandlerChain
¶
Bases: object
Abstract class containing Request Handler and corresponding Interceptors.
request_handler
()¶
request_interceptors
()¶
response_interceptors
()¶
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: AbstractRequestHandlerChainask_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: boolexecute
(handler_input, handler)¶
Executes the handler with the provided dispatch input.
Parameters:Result executed by passing handler_input to handler.
Return type:Union[None, Output]
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:Boolean whether handler can handle exception or not.
Return type:handle
(handler_input, exception)¶
Process the dispatch input and exception.
Parameters:Optional output object to serve as dispatch return.
Return type:Union[None, Output]
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.
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.
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
¶
request_interceptors
¶
response_interceptors
¶
add_request_interceptor
(interceptor)¶
Add interceptor to Request Interceptors list.
add_response_interceptor
(interceptor)¶
Add interceptor to Response Interceptors list.
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]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:Result executed by passing handler_input to handler.
Return type:Union[None, Output]
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.
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
.
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: Noneadd_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.
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:boolean if this type of request can be handled by this skill.
Return type:invoke
(event, context)¶
Invokes the dispatcher, to handle the skill input and return a skill output.
Parameters:output generated by handling the request.
Return type:SkillOutput
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: Noneadd_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.
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.
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.
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.
create
()¶
Create a skill object using the registered components.
Returns: a skill object that can be used for invocation. Return type: AbstractSkillRetroSearch 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