{ "info": { "author": "Johann BICH", "author_email": "johannbich@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# Event Gateway Python SDK\n\nPython library for interacting with the [Event Gateway](https://github.com/serverless/event-gateway).\n\n## Contents\n\n- [Background](#background)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Constructor](#constructor)\n- [Available Functions](#available-functions)\n- [Contributing](#contributing)\n\n## Background\n\nThis is the Python SDK for interacting with the [Event Gateway](https://github.com/serverless/event-gateway), the hub for connecting events to serverless functions.\n\n## Installation\n\n```\npip install event-gateway-sdk\n```\n\n## Usage\n\nUse the `emit` command to emit a [CloudEvent](https://github.com/cloudevents/spec) payload to your Event Gateway. The event will be received by any function that is subscribed to your event.\n\n```python\nfrom eventgateway import EventGateway\n\neg = EventGateway(url=\"https://mytenant-myapp.slsgateway.com\")\ncloudEvent = {\n \"eventType\": \"user.created\",\n \"cloudEventsVersion\": \"0.1\",\n \"source\": \"/services/users\",\n \"data\": {\n \"userId\": \"foo\",\n \"userName\": \"bar\"\n }\n}\neg.emit(cloudEvent=configData, path=\"/user/send-mail-user\")\n```\n\nThe `emit()` function takes three arguments: \n- an `event` which is a valid CloudEvent,\n- a `path` which is the path associated to the function (default: `/`)\n- a `headers` object that represents the headers sent to the gateway (default: `{\"Content-type\": \"application/json\"}`)\n\nThe function returns a request object. If your event has a `sync` subscription attached, the `fetch` response will have the status code and body from the subscription. If not, the response will return a `202 Accepted` status code with an empty body.\n\n## Constructor\n\nIn the example above, we created an Event Gateway client using the application URL from the [hosted Event Gateway](https://dashboard.serverless.com/) provided by Serverless, Inc. \n\nYou can also use the Event Gateway SDK with your own, self-hosted Event Gateway. Constructor details are listed below.\n\n**Parameters**\n\n- `url` - `string` - optional, Events API URL, default: `http://localhost:4000`\n- `space` - `string` - optional, space name, default: `default`\n- `configurationUrl` - `string` - optional, Configuration API URL. By default, it's the same as `url` but with `4001` port\n- `connectorUrl` - `string` - optional, Connector API URL. By default, it's the same as `url` but with `4002` port\n- `accessKey` - `string` - optional, access key for hosted Event Gateway. Access key is required for using Configuration API methods on hosted Event Gateway\n\n**Example**\n\n```python\nfrom eventgateway import EventGateway\n\neg = EventGateway(url=\"https://mytenant-myapp.slsgateway.com\", space=\"user\")\n```\n\n## Available Functions\n\n### checkConnection\n\nUsed to check the connectivity to the Event Gateway (using the `/v1/status` endpoint).\n\n**Example**\n\n```python\nfrom eventgateway import EventGateway\n\neg = EventGateway()\nif eg.checkConnection():\n print(\"Connection succesfull\")\nelse:\n print(\"Issue while connecting\")\n```\n\n### printConfig\n\nUtility to print the current configuration.\n\n**Example**\n\n```python\nfrom eventgateway import EventGateway\n\neg = EventGateway()\neg.printConfig()\n```\n\n### createEventType\n\nFunction to create an event type.\n\n**Example**\n\n```python\nfrom eventgateway import EventGateway\n\neventtype = {\n \"name\": \"http.request\"\n}\neg = EventGateway()\neg.createEventType(eventtype)\n```\n\n### getEventType\n\nFunction to get an event type.\n\n**Example**\n\n```python\nfrom eventgateway import EventGateway\n\neg = EventGateway()\neg.getEventType(\"user.created\")\n```\n\n### getAllEventType\n\nFunction to get all event type.\n\n**Example**\n\n```python\nfrom eventgateway import EventGateway\n\neg = EventGateway()\neg.getAllEventType()\n```\n\n### createFunction\n\nFunction to create a function trigger.\n\n**Example**\n\n```python\nfrom eventgateway import EventGateway\n\nfunction = {\n \"functionId\": \"new-user\",\n \"type\": \"http\",\n \"provider\":{\n \"url\": \"http://myapp.com/user/new\"\n }\n}\neg = EventGateway()\neg.createFunction(function)\n```\n\n### getFunction\n\nFunction to get a function.\n\n**Example**\n\n```python\nfrom eventgateway import EventGateway\n\neg = EventGateway()\neg.getFunction(\"new-user\")\n```\n\n### getAllFunction\n\nFunction to get all functions.\n\n**Example**\n\n```python\nfrom eventgateway import EventGateway\n\neg = EventGateway()\neg.getAllFunction()\n```\n\n### createSubscription\n\nFunction to subscribe to a function.\n\n**Example**\n\n```python\nfrom eventgateway import EventGateway\n\nsubscription = {\n \"functionId\": \"new-user\",\n \"event\": \"http\",\n \"method\": \"POST\",\n \"path\": \"/user/new\",\n \"eventType\": \"http.request\",\n \"type\": \"async\"\n}\neg = EventGateway()\neg.createSubscription(subscription)\n```\n\n### getSubscription\n\nFunction to get a subscription.\n\n**Example**\n\n```python\nfrom eventgateway import EventGateway\n\neg = EventGateway()\neg.getSubscription(\"YXN5bmMsaHR0cC5yZXF1ZXN0LG5ldy11c2VyLW9wZW5wYWFzLCUyRmppcmE\")\n```\n\n### getAllSubscription\n\nFunction to get all subscription.\n\n**Example**\n\n```python\nfrom eventgateway import EventGateway\n\neg = EventGateway()\neg.getAllSubscription()\n```\n\n## Contribute\n\nTBD\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/kalote/event-gateway-sdk", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "event-gateway-sdk", "package_url": "https://pypi.org/project/event-gateway-sdk/", "platform": "", "project_url": "https://pypi.org/project/event-gateway-sdk/", "project_urls": { "Homepage": "https://github.com/kalote/event-gateway-sdk" }, "release_url": "https://pypi.org/project/event-gateway-sdk/1.2.0/", "requires_dist": [ "requests" ], "requires_python": "", "summary": "Event Gateway Python SDK", "version": "1.2.0" }, "last_serial": 4843860, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "e1468bacb1512493694c2297bc82b295", "sha256": "cbf4c6f0e0cf70a7a84b8edc5552264868b471a4ce6557dab5e37f9aff36f00f" }, "downloads": -1, "filename": "event_gateway_sdk-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "e1468bacb1512493694c2297bc82b295", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5462, "upload_time": "2019-02-18T08:54:35", "url": "https://files.pythonhosted.org/packages/2d/c5/5bf10948b7a6a8d809de191fa59031a0f435b2a7ff41ed8a14570ff185b4/event_gateway_sdk-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b9e006e430ab2c5cda61cf9f4da9cf69", "sha256": "754584504d9d228c1703a6435cc99c82dd875dfc48cfcf83770480c556ebca7f" }, "downloads": -1, "filename": "event-gateway-sdk-1.0.0.tar.gz", "has_sig": false, "md5_digest": "b9e006e430ab2c5cda61cf9f4da9cf69", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4013, "upload_time": "2019-02-18T08:54:37", "url": "https://files.pythonhosted.org/packages/97/14/de8dc11ec7930621dec02a5fccc50cd4014b1148f7ad9de5991b267963d3/event-gateway-sdk-1.0.0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "719ad79fc58a0a97c1cee7e853bf8345", "sha256": "fc64895b6fd44634b8573bc9b190d1d8f037832f6e5bc4c4a1dc089c4ccc0438" }, "downloads": -1, "filename": "event_gateway_sdk-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "719ad79fc58a0a97c1cee7e853bf8345", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5760, "upload_time": "2019-02-19T10:45:05", "url": "https://files.pythonhosted.org/packages/eb/83/d762699110468e141f96bd3ada436e08bec35732efaeea245ac1a4e4b7ec/event_gateway_sdk-1.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "669b950717b79a8edda7eae80b79fd26", "sha256": "dac084a8b39e15467697ea3cb885a346a6675f9d7fe9e63af2573e846df6c978" }, "downloads": -1, "filename": "event-gateway-sdk-1.1.0.tar.gz", "has_sig": false, "md5_digest": "669b950717b79a8edda7eae80b79fd26", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4401, "upload_time": "2019-02-19T10:45:07", "url": "https://files.pythonhosted.org/packages/31/54/b99e49be3bb8c8c6ebf482dabb59828db413d0e61369ab22c8fa00b7a92f/event-gateway-sdk-1.1.0.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "d95d79b4c9613a313b8ba219a2c5b1e9", "sha256": "1a486eac53da6ffd6b498349e84137ec780a29b88f04f6f024543f56a285052a" }, "downloads": -1, "filename": "event_gateway_sdk-1.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "d95d79b4c9613a313b8ba219a2c5b1e9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6296, "upload_time": "2019-02-20T05:56:46", "url": "https://files.pythonhosted.org/packages/d5/3d/28a27dfe369e6946d8c5312d8f278b7172a886ebfe701ddd4c9df32a7d4c/event_gateway_sdk-1.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a4997144669949f6fc61e307951d0795", "sha256": "025443adf667054e44a95833c83beb7f2458a9e755002ca3a3d3cde9e9ebe072" }, "downloads": -1, "filename": "event-gateway-sdk-1.2.0.tar.gz", "has_sig": false, "md5_digest": "a4997144669949f6fc61e307951d0795", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4931, "upload_time": "2019-02-20T05:56:47", "url": "https://files.pythonhosted.org/packages/52/1d/f720ac16ffaa2fcd706b149916d1db87ac076e41e0c2f1172c0beabd1eeb/event-gateway-sdk-1.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d95d79b4c9613a313b8ba219a2c5b1e9", "sha256": "1a486eac53da6ffd6b498349e84137ec780a29b88f04f6f024543f56a285052a" }, "downloads": -1, "filename": "event_gateway_sdk-1.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "d95d79b4c9613a313b8ba219a2c5b1e9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6296, "upload_time": "2019-02-20T05:56:46", "url": "https://files.pythonhosted.org/packages/d5/3d/28a27dfe369e6946d8c5312d8f278b7172a886ebfe701ddd4c9df32a7d4c/event_gateway_sdk-1.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a4997144669949f6fc61e307951d0795", "sha256": "025443adf667054e44a95833c83beb7f2458a9e755002ca3a3d3cde9e9ebe072" }, "downloads": -1, "filename": "event-gateway-sdk-1.2.0.tar.gz", "has_sig": false, "md5_digest": "a4997144669949f6fc61e307951d0795", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4931, "upload_time": "2019-02-20T05:56:47", "url": "https://files.pythonhosted.org/packages/52/1d/f720ac16ffaa2fcd706b149916d1db87ac076e41e0c2f1172c0beabd1eeb/event-gateway-sdk-1.2.0.tar.gz" } ] }