Relay SDK Reference Docs

These are auto-generated docs for the current version of the Python SDK


Client

Internal class for clients to interact with the metadata service

relay_sdk.client.new_session(api_url=None)

Create a new client session to the metadata API.

Parameters

api_url (Optional[str]) – host and port to communicate with the api server (optional)

Return type

Session

Returns

a Session object connected to the api server


Events

Generating events for the service to act on

class relay_sdk.events.Events(client)

Class for generating event payloads to the service API

emit(data, key=None)

Sends an event to the service.

Use this from a Trigger handler to start the workflow associated with the trigger.

Accepts a Mapping of data fields from the request payload that came in to the Trigger handler.

A key can be optionally provided to uniquely identify the event.

Return type

None


Interface

The main class for a client to connect to the Relay service API

class relay_sdk.interface.Dynamic(name, parent=None)

A query interface for inspecting a spec.

This class allows arbitrary traversal that can be converted to a query to the metadata API.

class relay_sdk.interface.Interface(api_url=None, configure_logging=None)

An Interface object connects client code to the metadata service.

property events: relay_sdk.events.Events

Accessor for Events methods

Return type

Events

get(q=None)

Retrieve values from the metadata service

Parameters

q (Union[Dynamic, str, None]) – A particular parameter to query the value of.

Return type

Any

Returns

The value of the queried parameter as a string. If no query was provided, all available parameters will be returned in a json map

property outputs: relay_sdk.outputs.Outputs

Accessor for Outputs methods

Return type

Outputs

property workflows: relay_sdk.workflows.Workflows

Accessor for Workflows methods

Return type

Workflows

exception relay_sdk.interface.UnresolvableException

Outputs

Outputs allow a step to write data that will be available for later steps

class relay_sdk.outputs.Outputs(client)

Use Outputs to write keys to the metadata service that later steps can retrieve

set(name, value)

Set writes a value of a given name to the service

Parameters
  • name (str) – a string containing the key name to write

  • value (Any) – the value of the key to be written. Can be any data type that can serialize to JSON

Return type

None


Workflows

Allows a step to run a workflow

class relay_sdk.workflows.Workflows(client)

Use Workflows to run a workflow with parameters

run(name, parameters={})

run starts a workflow with name and parameters

Parameters
  • name (str) – a string containing the name of the workflow

  • parameters (Mapping[str, Any]) – an object that can serialize to JSON

Return type

None


Webhook

A helper class for building Trigger webhooks for Relay

exception relay_sdk.webhook.PortParseError
class relay_sdk.webhook.WebhookServer(app, *, termination_policy=None, port=None)

Instantiate a WebhookServer class to handle incoming webhook payloads

They should use the serve_forever() startup method, because Relay will manage the lifecycle of the trigger container.

They should not expect any state to be preserved between requests, nor rely on any persistence on the local container filesystem.