-
-
Notifications
You must be signed in to change notification settings - Fork 314
add support for OGC API Publish-Subscribe Workflow - Part 1: Core (#2146) #2220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7600c89
add support for OGC API Publish-Subscribe Workflow - Part 1: Core (#2…
tomkralidis b0bc695
update docs
tomkralidis d021f6c
update docs
tomkralidis 0149554
fix API deletion on not found items in backend
tomkralidis 4ccd1b7
fix ref
tomkralidis d3952ff
fix docs
tomkralidis 982edfb
add AsyncAPI support
tomkralidis 4c1a87f
fix tests
tomkralidis a37bc8a
add exception handling
tomkralidis 048106c
update docs
tomkralidis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| .. _pubsub: | ||
|
|
||
| Publish-Subscribe integration (Pub/Sub) | ||
| ======================================= | ||
|
|
||
| pygeoapi supports Publish-Subscribe (Pub/Sub) integration by implementing | ||
| the `OGC API Publish-Subscribe Workflow - Part 1: Core`_ (draft) specification. | ||
|
|
||
| Pub/Sub integration can be enabled by defining a broker that pycsw can use to | ||
| publish notifications on given topics using CloudEvents (as per the specification). | ||
|
|
||
| When enabled, core functionality of Pub/Sub includes: | ||
|
|
||
| - providing an AsyncAPI document (JSON and HTML) | ||
| - providing the following links on the OGC API landing page: | ||
|
|
||
| - the broker link (``rel=hub`` link relation) | ||
| - the AsyncAPI JSON link (``rel=service-desc`` link relation and ``type=application/asyncapi+json`` media type) | ||
| - the AsyncAPI HTML link (``rel=service-doc`` link relation and ``type=text/html`` media type) | ||
|
|
||
| - sending a notification message on the following events: | ||
|
|
||
| - feature or record transactions (create, replace, update, delete) | ||
| - process executions/job creation | ||
|
|
||
| AsyncAPI | ||
| -------- | ||
|
|
||
| `AsyncAPI`_ is the event-driven equivalent to :ref:`openapi` | ||
|
|
||
| The official AsyncAPI specification can be found on the `AsyncAPI`_ website. pygeoapi supports AsyncAPI version 3.0.0. | ||
|
|
||
| AsyncAPI is an optional capability in pygeoapi. To enable AsyncAPI, the following steps are required: | ||
|
|
||
| - defining a ``pubsub`` section in configuration (see :ref:`configuration` and :ref:`brokers` for more information) | ||
| - generating an AsyncAPI document | ||
| - setting the ``PYGEOAPI_ASYNCAPI`` environment variable | ||
|
|
||
| Creating the AsyncAPI document | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| The AsyncAPI document is a YAML or JSON configuration which is generated from the pygeoapi configuration, and describes the server information, channels and the message payloads structures. | ||
|
|
||
| To generate the AsyncAPI document, run the following: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| pygeoapi asyncapi generate /path/to/my-pygeoapi-config.yml | ||
|
|
||
| This will dump the AsyncAPI document as YAML to your system's ``stdout``. To save to a file on disk, run: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| pygeoapi asyncapi generate /path/to/my-pygeoapi-config.yml --output-file /path/to/my-pygeoapi-asyncapi.yml | ||
|
|
||
| To generate the AsyncAPI document as JSON, run: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| pygeoapi asyncapi generate /path/to/my-pygeoapi-config.yml --format json --output-file /path/to/my-pygeoapi-asyncapi.json | ||
|
|
||
| .. note:: | ||
| Generate as YAML or JSON? If your AsyncAPI YAML definition is slow to render as JSON, | ||
| saving as JSON to disk will help with performance at run-time. | ||
|
|
||
| .. note:: | ||
| The AsyncAPI document provides detailed information on query parameters, and dataset | ||
| property names and their data types. Whenever you make changes to your pygeoapi configuration, | ||
| always refresh the accompanying AsyncAPI document. | ||
|
|
||
| Validating the AsyncAPI document | ||
| -------------------------------- | ||
|
|
||
| To ensure your AsyncAPI document is valid, pygeoapi provides a validation | ||
| utility that can be run as follows: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| pygeoapi asyncapi validate /path/to/my-pygeoapi-asyncapi.yml | ||
|
|
||
| .. _brokers: | ||
|
|
||
| Brokers | ||
| ------- | ||
|
|
||
| The following protocols are supported: | ||
|
|
||
| MQTT | ||
| ^^^^ | ||
|
|
||
| Example directive: | ||
|
|
||
| .. code-block:: yaml | ||
|
|
||
| pubsub: | ||
| name: MQTT | ||
| broker: | ||
| url: mqtt://localhost:1883 | ||
| channel: messages/a/data # optional | ||
| hidden: false # default | ||
|
|
||
| HTTP | ||
| ^^^^ | ||
|
|
||
| Example directive: | ||
|
|
||
| .. code-block:: yaml | ||
|
|
||
| pubsub: | ||
| name: HTTP | ||
| broker: | ||
| url: https://ntfy.sh | ||
| channel: messages-a-data # optional | ||
| hidden: true # default false | ||
|
|
||
| .. note:: | ||
|
|
||
| For any Pub/Sub endpoints requiring authentication, encode the ``url`` value as follows: | ||
|
|
||
| * ``mqtt://username:password@localhost:1883`` | ||
| * ``https://username:password@localhost`` | ||
|
|
||
| As with any section of the pygeoapi configuration, environment variables may be used as needed, for example | ||
| to set username/password information in a URL. If ``pubsub.broker.url`` contains authentication, and | ||
| ``pubsub.broker.hidden`` is ``false``, the authentication information will be stripped from the URL | ||
| before displaying it on the landing page. | ||
|
|
||
| .. note:: | ||
|
|
||
| If a ``channel`` is defined, it is used as a prefix to the relevant OGC API endpoint used. | ||
|
|
||
| If a ``channel`` is not defined, only the relevant OGC API endpoint is used. | ||
|
|
||
| .. _`OGC API Publish-Subscribe Workflow - Part 1: Core`: https://docs.ogc.org/DRAFTS/25-030.html | ||
| .. _`AsyncAPI`: https://www.asyncapi.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.