flowserv.view.descriptor module

Serializer for the service descriptor.

class flowserv.view.descriptor.ServiceDescriptorSerializer

Bases: object

Default serializer for the service descriptor.

from_config(env: Dict, username: Optional[str] = None) Dict

Get serialized descriptor with basic information from values in the given configuration settings.

Parameters
  • env (dict, default=None) – Dictionary that provides access to configuration parameter values.

  • username (string, default=None) – Optional name for an authenticated user.

Return type

dict

get_name(doc: Dict) str

Get the name value from the given document.

Parameters

doc (dict) – Serialization of a service descriptor.

Return type

string

get_routes(doc: Dict, routes: Dict) str

Get the user name from the given document.

Parameters
  • doc (dict) – Serialization of a service descriptor.

  • routes (dict) – Dictionary with Url patterns for supported API routes. This will override patterns that may be defined in the given serialized descriptor.

Return type

string

get_url(doc: Dict) str

Get the base Url from the given document.

Parameters

doc (dict) – Serialization of a service descriptor.

Return type

string

get_username(doc: Dict) str

Get the user name from the given document.

Parameters

doc (dict) – Serialization of a service descriptor.

Return type

string

get_version(doc: Dict) str

Get the version information from the given document.

Parameters

doc (dict) – Serialization of a service descriptor.

Return type

string

service_descriptor(name: str, version: str, url: str, routes: Dict, username: Optional[str] = None) Dict

Serialization of the service descriptor. The descriptor contains the service name, version, and a list of route patterns. The optional user name indicates whether a request for the service descriptor contained a valid access token. If the user name is not None it will be included in the service descriptor.

Parameters
  • name (string) – Service name.

  • version (string) – Service version number.

  • url (string) – Base Url for the service API. This is the prefix for all Url routes.

  • username (string, default=None) – Name of the user that was authenticated by a given access token.

Return type

dict