-
Notifications
You must be signed in to change notification settings - Fork 3.3k
CloudEvents/EG Events must recognize magic events #19922
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
Rakshith Bhyravabhotla (rakshith91)
merged 23 commits into
Azure:main
from
rakshith91:magic_events
Aug 4, 2021
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
5c85461
Draft for magic events
rakshith91 944ed4e
Update sdk/eventgrid/azure-eventgrid/azure/eventgrid/_models.py
7b0bb8f
Update sdk/eventgrid/azure-eventgrid/azure/eventgrid/_models.py
56bb5d7
Update sdk/eventgrid/azure-eventgrid/azure/eventgrid/_models.py
b2a90e2
duplicate code
rakshith91 393ccb0
lint
rakshith91 d9c5481
mypy
rakshith91 e38a4d5
changelog
rakshith91 ce32b66
tests
rakshith91 b19d370
ci
rakshith91 2376e4f
lint
rakshith91 d0fa553
rename + static method
rakshith91 d2dbd4a
lint
rakshith91 4112175
Merge branch 'main' into magic_events
33163df
remove method
rakshith91 15f3bdf
Merge branch 'magic_events' of github.com:rakshith91/azure-sdk-for-py…
rakshith91 70a0168
Update sdk/eventgrid/azure-eventgrid/azure/eventgrid/_models.py
40ca6d6
add a from_json method
rakshith91 1926b64
comments
rakshith91 f6b6593
handle type error
rakshith91 ee4b1ab
Revert "handle type error"
rakshith91 262b29b
mypy fix
rakshith91 5a11e22
rename param to event
rakshith91 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # coding=utf-8 | ||
| # -------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
|
|
||
| # ========================================================================== | ||
| # This file contains duplicate code that is shared with azure-eventgrid. | ||
| # Both the files should always be identical. | ||
| # ========================================================================== | ||
|
|
||
|
|
||
|
|
||
| import json | ||
| from azure.core.exceptions import raise_with_traceback | ||
|
|
||
| def _get_json_content(obj): | ||
| """Event mixin to have methods that are common to different Event types | ||
| like CloudEvent, EventGridEvent etc. | ||
| """ | ||
| msg = "Failed to load JSON content from the object." | ||
| try: | ||
| # storage queue | ||
| return json.loads(obj.content) | ||
| except ValueError as err: | ||
| raise_with_traceback(ValueError, msg, err) | ||
| except AttributeError: | ||
| # eventhubs | ||
| try: | ||
| return json.loads(next(obj.body))[0] | ||
| except KeyError: | ||
| # servicebus | ||
| return json.loads(next(obj.body)) | ||
| except ValueError as err: | ||
| raise_with_traceback(ValueError, msg, err) | ||
| except: # pylint: disable=bare-except | ||
| try: | ||
| return json.loads(obj) | ||
| except ValueError as err: | ||
| raise_with_traceback(ValueError, msg, err) |
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.