{"id":15022607,"url":"https://github.com/puppetlabs/relay-sdk-python","last_synced_at":"2025-08-16T18:32:45.585Z","repository":{"id":39968121,"uuid":"271898649","full_name":"puppetlabs/relay-sdk-python","owner":"puppetlabs","description":"Python SDK for integrating with Relay","archived":false,"fork":false,"pushed_at":"2022-08-17T19:37:58.000Z","size":86,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-11-05T17:08:26.534Z","etag":null,"topics":["relay"],"latest_commit_sha":null,"homepage":"https://relay-sdk-python.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/puppetlabs.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null}},"created_at":"2020-06-12T22:10:25.000Z","updated_at":"2022-04-28T20:55:41.000Z","dependencies_parsed_at":"2022-09-10T15:11:50.984Z","dependency_job_id":null,"html_url":"https://github.com/puppetlabs/relay-sdk-python","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puppetlabs%2Frelay-sdk-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puppetlabs%2Frelay-sdk-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puppetlabs%2Frelay-sdk-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puppetlabs%2Frelay-sdk-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/puppetlabs","download_url":"https://codeload.github.com/puppetlabs/relay-sdk-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230049994,"owners_count":18164984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["relay"],"created_at":"2024-09-24T19:58:11.658Z","updated_at":"2024-12-17T01:43:55.390Z","avatar_url":"https://github.com/puppetlabs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Relay Python SDK\n================\n\nInstallation\n------------\n\nThe SDK is available to install via `pip`:\n\n.. code-block:: console\n\n  pip install relay-sdk\n\nIf you use the `relaysh/core:latest-python \u003chttps://hub.docker.com/r/relaysh/core/tags\u003e`_ container image as your base\nimage, it'll be pre-installed.\n\nUsage\n-----\nThe main purpose of the SDK is to provide helpers for interacting with Relay's\nmetadata service. Each container that runs in Relay has access to this service,\nwhich allows the container to read and write key-value data, emit events, and\ngenerate logs.\n\nAccessing Data from the step spec\n---------------------------------\n\nThe `Interface class \u003c./reference.html#module-relay_sdk.interface\u003e`_ is the primary way to interact with the service.\nImport it and instantiate an object, then call methods on that object to access metadata,\nwhich comes from the ``spec`` section of the step and global Connection information.\nThe ``Dynamic`` class provides syntactic sugar for getting data like connection credentials, \nworkflow-specific parameters, and secrets. It represents nested data structures as dot-separated\nmethod accessors.\n\n.. code-block:: python\n\n  from relay_sdk import Interface, Dynamic as D\n\n  relay = Interface()\n  azuresecret = relay.get(D.azure.connection.secret) # using Dynamic\n  azureclient = relay.get('azure[\"connection\"][\"clientID\"]') # same as above\n  secret = relay.get(D.mysecret)\n  relay.outputs.set(\"outputkey\",\"This will be the value of outputkey\")\n\nRunning Workflows\n-----------------\n\nThe `Workflow class \u003c./reference.html#module-relay_sdk.workflows\u003e`_ offers the method ``run``\nto run a workflow.\n\nUse the following to run the workflow ``my_workflow`` with parameter ``param_name`` and value ``param_value``:\n\n.. code-block:: python\n\n  from relay_sdk import Interface\n\n  relay = Interface()\n  relay.workflows.run('my_workflow', parameters={'param_name':'param_value'})\n\nWebhook Triggers\n----------------\n\nThe `WebhookServer class \u003c./reference.html#module-relay_sdk.webhook\u003e`_ provides a\nhelper that sets up a webserver to handle incoming requests for Trigger actions. \n\nThis example, from the `Docker Hub integration \u003chttps://github.com/relay-integrations/relay-dockerhub/\u003e`_, makes use of\nthe Interface class to access the ``events.emit`` method, which will cause\nthe workflow associated with this trigger to be run with the inline mapping\nof workflow parameters to values extracted from the webhook payload.\n\nThe WebhookServer class can run any WSGI_ or ASGI_ application passed to it. The\nintegrations the Relay team develops internally use the Quart_ web app framework.\n\n.. _WSGI: https://www.python.org/dev/peps/pep-3333/\n.. _ASGI: https://asgi.readthedocs.io/en/latest/specs/main.html\n.. _Quart: https://pgjones.gitlab.io/quart/index.html\n\n.. code-block:: python\n\n  from relay_sdk import Interface, WebhookServer\n  from quart import Quart, request, jsonify, make_response\n\n  relay = Interface()\n  app = Quart('image-pushed')\n\n  @app.route('/', methods=['POST'])\n  async def handler():\n      event_payload = await request.get_json()\n\n      if event_payload is None:\n          return await make_response(jsonify(message='not a valid Docker Hub event'), 400)\n\n      pd = event_payload['push_data']\n      rd = event_payload['repository']\n\n      relay.events.emit({\n          'pushedAt': pd['pushed_at'],\n          'pusher': pd['pusher'],\n          'tag': pd['tag'],\n          'name': rd['repo_name']\n      })\n\n      return await make_response(jsonify(message='success'), 200)\n\n\n  if __name__ == '__main__':\n      WebhookServer(app).serve_forever()\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpuppetlabs%2Frelay-sdk-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpuppetlabs%2Frelay-sdk-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpuppetlabs%2Frelay-sdk-python/lists"}