-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Support for CNCF cloud event #21236
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
Support for CNCF cloud event #21236
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ac5398a
Support for CNCF cloud event
rakshith91 9524fa9
changelog
rakshith91 67a3323
lint
rakshith91 4e3db09
Update sdk/eventgrid/azure-eventgrid/dev_requirements.txt
7dc5036
comments
rakshith91 289404d
ci plus do
rakshith91 a8ac686
tests
rakshith91 4d51dc9
Merge branch 'main' into cncfcloud
e7916d7
comments
rakshith91 c05b988
readme
rakshith91 99bddbc
comments
rakshith91 89e3825
Update _helpers.py
ec58ab0
lint
rakshith91 df76fe9
Update _helpers.py
708434c
Update _helpers.py
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
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
43 changes: 43 additions & 0 deletions
43
...eventgrid/azure-eventgrid/samples/async_samples/sample_publish_cncf_cloud_events_async.py
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,43 @@ | ||
| # -------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| """ | ||
| FILE: sample_publish_cncf_cloud_events_async.py | ||
| DESCRIPTION: | ||
| This sample demonstrates creating sending a cloud event from the CNCF library. | ||
| USAGE: | ||
| python sample_publish_cncf_cloud_events_async.py | ||
| Set the environment variables with your own values before running the sample: | ||
| 1) CLOUD_ACCESS_KEY - The access key of your eventgrid account. | ||
| 2) CLOUD_TOPIC_HOSTNAME - The topic hostname. Typically it exists in the format | ||
| "https://<YOUR-TOPIC-NAME>.<REGION-NAME>.eventgrid.azure.net/api/events". | ||
| """ | ||
| import os | ||
| import asyncio | ||
| from azure.eventgrid.aio import EventGridPublisherClient | ||
| from azure.core.credentials import AzureKeyCredential | ||
| from cloudevents.http import CloudEvent | ||
|
|
||
| topic_key = os.environ["CLOUD_ACCESS_KEY"] | ||
| endpoint = os.environ["CLOUD_TOPIC_HOSTNAME"] | ||
|
|
||
|
|
||
| async def publish(): | ||
|
|
||
| credential = AzureKeyCredential(topic_key) | ||
| client = EventGridPublisherClient(endpoint, credential) | ||
| await client.send([ | ||
| CloudEvent( | ||
| attributes={ | ||
| "type": "cloudevent", | ||
| "source": "/cncf/cloud/event/1.0", | ||
| "subject": "testingcncfevent" | ||
| }, | ||
| data=b'This is a cncf cloud event.', | ||
| ) | ||
| ]) | ||
|
|
||
| if __name__ == '__main__': | ||
| asyncio.run(publish()) |
37 changes: 37 additions & 0 deletions
37
sdk/eventgrid/azure-eventgrid/samples/sync_samples/sample_publish_cncf_cloud_events.py
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,37 @@ | ||
| # -------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| """ | ||
| FILE: sample_publish_cncf_cloud_events.py | ||
| DESCRIPTION: | ||
| This sample demonstrates creating sending a cloud event from the CNCF library. | ||
| USAGE: | ||
| python sample_publish_cncf_cloud_events.py | ||
| Set the environment variables with your own values before running the sample: | ||
| 1) CLOUD_ACCESS_KEY - The access key of your eventgrid account. | ||
| 2) CLOUD_TOPIC_HOSTNAME - The topic hostname. Typically it exists in the format | ||
| "https://<YOUR-TOPIC-NAME>.<REGION-NAME>.eventgrid.azure.net/api/events". | ||
| """ | ||
| import os | ||
| from azure.eventgrid import EventGridPublisherClient | ||
| from azure.core.credentials import AzureKeyCredential | ||
| from cloudevents.http import CloudEvent | ||
|
|
||
| topic_key = os.environ["CLOUD_ACCESS_KEY"] | ||
| endpoint = os.environ["CLOUD_TOPIC_HOSTNAME"] | ||
|
|
||
| credential = AzureKeyCredential(topic_key) | ||
| client = EventGridPublisherClient(endpoint, credential) | ||
|
|
||
| client.send([ | ||
| CloudEvent( | ||
| attributes={ | ||
| "type": "cloudevent", | ||
| "source": "/cncf/cloud/event/1.0", | ||
| "subject": "testingcncfevent" | ||
| }, | ||
| data=b'This is a cncf cloud event.', | ||
| ) | ||
| ]) |
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
38 changes: 38 additions & 0 deletions
38
...azure-eventgrid/tests/recordings/test_cncf_events.test_send_cloud_event_data_as_list.yaml
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,38 @@ | ||
| interactions: | ||
| - request: | ||
| body: '[{"type": "com.example.sampletype1", "source": "https://example.com/event-producer", | ||
| "specversion": "1.0", "id": "84b41e66-8127-4f46-850e-d62e8386e87e", "time": | ||
| "2021-10-25T03:07:58.245751+00:00", "data": "hello world"}]' | ||
| headers: | ||
| Accept: | ||
| - '*/*' | ||
| Accept-Encoding: | ||
| - gzip, deflate | ||
| Connection: | ||
| - keep-alive | ||
| Content-Length: | ||
| - '220' | ||
| Content-Type: | ||
| - application/cloudevents-batch+json; charset=utf-8 | ||
| User-Agent: | ||
| - azsdk-python-eventgrid/4.7.0 Python/3.7.3 (Windows-10-10.0.18362-SP0) | ||
| method: POST | ||
| uri: https://cloudeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 | ||
| response: | ||
| body: | ||
| string: '' | ||
| headers: | ||
| api-supported-versions: | ||
| - '2018-01-01' | ||
| content-length: | ||
| - '0' | ||
| date: | ||
| - Mon, 25 Oct 2021 03:07:57 GMT | ||
| server: | ||
| - Microsoft-HTTPAPI/2.0 | ||
| strict-transport-security: | ||
| - max-age=31536000; includeSubDomains | ||
| status: | ||
| code: 200 | ||
| message: OK | ||
| version: 1 |
38 changes: 38 additions & 0 deletions
38
...tgrid/tests/recordings/test_cncf_events.test_send_cloud_event_data_base64_using_data.yaml
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,38 @@ | ||
| interactions: | ||
| - request: | ||
| body: '[{"type": "com.example.sampletype1", "source": "https://example.com/event-producer", | ||
| "specversion": "1.0", "id": "630d2dfe-6a48-455b-bd59-7c08cd070226", "time": | ||
| "2021-10-25T03:07:58.780277+00:00", "data_base64": "b''hello world''"}]' | ||
| headers: | ||
| Accept: | ||
| - '*/*' | ||
| Accept-Encoding: | ||
| - gzip, deflate | ||
| Connection: | ||
| - keep-alive | ||
| Content-Length: | ||
| - '230' | ||
| Content-Type: | ||
| - application/cloudevents-batch+json; charset=utf-8 | ||
| User-Agent: | ||
| - azsdk-python-eventgrid/4.7.0 Python/3.7.3 (Windows-10-10.0.18362-SP0) | ||
| method: POST | ||
| uri: https://cloudeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 | ||
| response: | ||
| body: | ||
| string: '' | ||
| headers: | ||
| api-supported-versions: | ||
| - '2018-01-01' | ||
| content-length: | ||
| - '0' | ||
| date: | ||
| - Mon, 25 Oct 2021 03:07:58 GMT | ||
| server: | ||
| - Microsoft-HTTPAPI/2.0 | ||
| strict-transport-security: | ||
| - max-age=31536000; includeSubDomains | ||
| status: | ||
| code: 200 | ||
| message: OK | ||
| version: 1 |
38 changes: 38 additions & 0 deletions
38
...id/azure-eventgrid/tests/recordings/test_cncf_events.test_send_cloud_event_data_dict.yaml
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,38 @@ | ||
| interactions: | ||
| - request: | ||
| body: '[{"type": "com.example.sampletype1", "source": "https://example.com/event-producer", | ||
| "specversion": "1.0", "id": "f687bede-e758-4bbd-aec9-d3f284b92238", "time": | ||
| "2021-10-25T03:07:59.100133+00:00", "data": {"message": "Hello World!"}}]' | ||
| headers: | ||
| Accept: | ||
| - '*/*' | ||
| Accept-Encoding: | ||
| - gzip, deflate | ||
| Connection: | ||
| - keep-alive | ||
| Content-Length: | ||
| - '234' | ||
| Content-Type: | ||
| - application/cloudevents-batch+json; charset=utf-8 | ||
| User-Agent: | ||
| - azsdk-python-eventgrid/4.7.0 Python/3.7.3 (Windows-10-10.0.18362-SP0) | ||
| method: POST | ||
| uri: https://cloudeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 | ||
| response: | ||
| body: | ||
| string: '' | ||
| headers: | ||
| api-supported-versions: | ||
| - '2018-01-01' | ||
| content-length: | ||
| - '0' | ||
| date: | ||
| - Mon, 25 Oct 2021 03:07:59 GMT | ||
| server: | ||
| - Microsoft-HTTPAPI/2.0 | ||
| strict-transport-security: | ||
| - max-age=31536000; includeSubDomains | ||
| status: | ||
| code: 200 | ||
| message: OK | ||
| version: 1 |
38 changes: 38 additions & 0 deletions
38
...id/azure-eventgrid/tests/recordings/test_cncf_events.test_send_cloud_event_data_none.yaml
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,38 @@ | ||
| interactions: | ||
| - request: | ||
| body: '[{"type": "com.example.sampletype1", "source": "https://example.com/event-producer", | ||
| "specversion": "1.0", "id": "0adea5e4-44e6-4c88-83f2-ab009c09ac43", "time": | ||
| "2021-10-25T03:07:59.496961+00:00", "data": null}]' | ||
| headers: | ||
| Accept: | ||
| - '*/*' | ||
| Accept-Encoding: | ||
| - gzip, deflate | ||
| Connection: | ||
| - keep-alive | ||
| Content-Length: | ||
| - '211' | ||
| Content-Type: | ||
| - application/cloudevents-batch+json; charset=utf-8 | ||
| User-Agent: | ||
| - azsdk-python-eventgrid/4.7.0 Python/3.7.3 (Windows-10-10.0.18362-SP0) | ||
| method: POST | ||
| uri: https://cloudeventgridtestegtopic.westus-1.eventgrid.azure.net/api/events?api-version=2018-01-01 | ||
| response: | ||
| body: | ||
| string: '' | ||
| headers: | ||
| api-supported-versions: | ||
| - '2018-01-01' | ||
| content-length: | ||
| - '0' | ||
| date: | ||
| - Mon, 25 Oct 2021 03:07:59 GMT | ||
| server: | ||
| - Microsoft-HTTPAPI/2.0 | ||
| strict-transport-security: | ||
| - max-age=31536000; includeSubDomains | ||
| status: | ||
| code: 200 | ||
| message: OK | ||
| version: 1 |
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.