-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[EGv2] Binary mode #32922
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
[EGv2] Binary mode #32922
Changes from 77 commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
ec73729
[EGv2] Build Release (#30325)
l0lawrence c7188d3
Beta LiveTests (#30728)
l0lawrence 7e5003c
[EGv2] Build Release (#30325)
l0lawrence 951a9d8
fix merge
l0lawrence 69d253b
dont go to generated before binary
l0lawrence 000e3b3
update patch
l0lawrence 97fb553
update patches
l0lawrence 2e7bb32
eventgrid client patch
l0lawrence 028484f
changes
l0lawrence 503c9e8
add
l0lawrence 92df675
update test
l0lawrence c2b9eed
update tyoe checking
l0lawrence 31f0c02
pass through binary_mode for now --
l0lawrence 67a7279
update patch aio
l0lawrence 54b2c43
add async func
l0lawrence 2bcb97f
update
l0lawrence 7a650bb
sys
l0lawrence db034eb
update kwargs
l0lawrence e83ac70
add Todo and start adding more tests
l0lawrence 0ec4a3a
update
l0lawrence 8647028
differentiate between binary and not
l0lawrence 2e3b639
update binary
l0lawrence 3a1b72a
no base64 in binary mode
l0lawrence 110f3f1
binary
l0lawrence 015d1f4
try JSONEncoder on everything if not str/bytes
l0lawrence 13f0ae3
update test
l0lawrence 79dba1b
update test
l0lawrence 47148f5
update changes
l0lawrence 0a1307d
whitespace
l0lawrence 9ca6f1d
space
l0lawrence 52845d3
remove commented
l0lawrence fb53f33
str serialize extensions?
l0lawrence 74c434d
xml test
l0lawrence cec8eaf
encode extensions as object
l0lawrence 08eacb6
update test
l0lawrence fd002c1
update extension serialization for deserialize
l0lawrence dec4248
move flag to operation level
l0lawrence 4eb1876
extra comma
l0lawrence 60ff404
dont raise httpresponse
l0lawrence 2b17321
update patch
l0lawrence 6fe171d
accept dict cloud events
l0lawrence bb8ba88
spacing
l0lawrence 633166e
remove content_type check
l0lawrence 3b37f20
add live test
l0lawrence 6b50b87
remove live test mark
l0lawrence bc997b2
update
l0lawrence efb5911
use env vars
l0lawrence 4e046c8
update test
l0lawrence 7db3968
only run live test
l0lawrence 1d74cda
comment
l0lawrence 0abd334
typo
l0lawrence 9495362
error incorrect
l0lawrence 58bd912
start comments
l0lawrence 205758e
update test
l0lawrence 67ac8d2
add sample
l0lawrence 35ecda1
update tests
l0lawrence 6611e67
update docstrings to add clarity
l0lawrence 5016b76
update err message
l0lawrence 1f07d6f
remove generated cloud event
l0lawrence dac9cf0
update sample
l0lawrence fc52a69
update
l0lawrence 502c371
update samples to include dict
l0lawrence 9a9c4b1
update patch
l0lawrence ba01c09
spacing
l0lawrence 6bcbb77
add comments
l0lawrence 464cd6b
formatting
l0lawrence 8d0bbe6
update doc
l0lawrence ee013cc
update tests
l0lawrence 5b0beac
update tests
l0lawrence 3bf9dd2
tests
l0lawrence 5c47708
skip tests for now
l0lawrence eeb1aaf
typo
l0lawrence df23b8b
add dict binary mode
l0lawrence b5b5236
update docstring
l0lawrence b21b5e6
update patch to allow throw error
l0lawrence 11f9560
first pass at comments
l0lawrence 89e889d
update patch eror
l0lawrence f3546d9
nit
l0lawrence 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
342 changes: 306 additions & 36 deletions
342
sdk/eventgrid/azure-eventgrid/azure/eventgrid/_operations/_patch.py
Large diffs are not rendered by default.
Oops, something went wrong.
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
51 changes: 51 additions & 0 deletions
51
...zure-eventgrid/samples/async_samples/eventgrid_client_samples/sample_binary_mode_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,51 @@ | ||
| # -------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| import os | ||
| import asyncio | ||
| import json | ||
| from azure.core.credentials import AzureKeyCredential | ||
| from azure.eventgrid.aio import EventGridClient | ||
| from azure.eventgrid.models import * | ||
| from azure.core.messaging import CloudEvent | ||
| from azure.core.exceptions import HttpResponseError | ||
|
|
||
|
|
||
| EVENTGRID_KEY: str = os.environ["EVENTGRID_KEY"] | ||
| EVENTGRID_ENDPOINT: str = os.environ["EVENTGRID_ENDPOINT"] | ||
| TOPIC_NAME: str = os.environ["EVENTGRID_TOPIC_NAME"] | ||
| EVENT_SUBSCRIPTION_NAME: str = os.environ["EVENTGRID_EVENT_SUBSCRIPTION_NAME"] | ||
|
|
||
| # Create a client | ||
| client = EventGridClient(EVENTGRID_ENDPOINT, AzureKeyCredential(EVENTGRID_KEY)) | ||
|
|
||
|
|
||
| async def run(): | ||
| async with client: | ||
| # Publish a CloudEvent | ||
| try: | ||
| # Publish CloudEvent in binary mode with str encoded as bytes | ||
| cloud_event_dict = {"data":b"HI", "source":"https://example.com", "type":"example", "datacontenttype":"text/plain"} | ||
| await client.publish_cloud_events(topic_name=TOPIC_NAME, body=cloud_event_dict) | ||
|
|
||
| # Publish CloudEvent in binary mode with json encoded as bytes | ||
| cloud_event = CloudEvent(data=json.dumps({"hello":"data"}).encode("utf-8"), source="https://example.com", type="example", datacontenttype="application/json") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. non-blocking, but might be helpful to add a comment to say what you're showing for each cloudEvent that you construct here. something like/better than: |
||
| await client.publish_cloud_events(topic_name=TOPIC_NAME, body=cloud_event, binary_mode=True) | ||
|
|
||
| receive_result = await client.receive_cloud_events( | ||
| topic_name=TOPIC_NAME, | ||
| event_subscription_name=EVENT_SUBSCRIPTION_NAME, | ||
| max_events=10, | ||
| max_wait_time=10, | ||
| ) | ||
| for details in receive_result.value: | ||
| cloud_event_received = details.event | ||
| print("CloudEvent: ", cloud_event_received) | ||
| print("Data: ", cloud_event_received.data) | ||
| except HttpResponseError: | ||
| raise | ||
|
|
||
| if __name__ == "__main__": | ||
| asyncio.get_event_loop().run_until_complete(run()) | ||
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.