Skip to content
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

Send EventGrid spec #12958

Closed
lmazuel opened this issue Aug 7, 2020 · 0 comments · Fixed by #13143
Closed

Send EventGrid spec #12958

lmazuel opened this issue Aug 7, 2020 · 0 comments · Fixed by #13143
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. Event Grid Messaging Messaging crew

Comments

@lmazuel
Copy link
Member

lmazuel commented Aug 7, 2020

After a lot of investigation and discussion with all party involved, drafting a spec for send of EventGrid. We might be near to be done with @t-swpill work, but for clarity needs to be written:

We shall have ONE send method only, that accepts different types of content:

  • A CloudEvent instance
  • A EventGridSchema instance
  • A dict, or any type
  • An explicit list of the three preceding format

For the later, we shall send the dict "as-is" on the wire, and not try any kind of client-side validation. Example, this is a valid way to send a Cloud Event:

client.send({
   "id": "foo",
   "source": "blo",
   "specversion":"1.0",
   "type": "blie",
   "data": {"joy":True}
})

The dict follow the CloudEvent spec, so there is no reason to not send it that way.

Implementation (important) detail: when sending a CloudEvent, we must set the Content-Type to "application/cloudevents-batch+json; charset=utf-8". This means in the dict case, we must detect if the dict is Cloud Event. We recommend using a predicate that checks:

  • All required Cloud Event attributest are provided: id/source/specversion/type
  • specversion has the value "1.0"

If the dict follow this structure, we send the JSON with application/cloudevents-batch+json; charset=utf-8, otherwise we use application/json

In case we want to be explicit:

client.send({
       "id": "foo",
       "source": "blo",
       "specversion":"1.0",
       "type": "blie",
       "data": {"joy":True}
   },
   content_type="application/json"
)

And list are supported:

client.send([{
   "id": "foo",
   "source": "blo",
   "specversion":"1.0",
   "type": "blie",
   "data": {"joy":True}
},{
   "id": "foo",
   "source": "blo",
   "specversion":"1.0",
   "type": "blie",
   "data": {"joy":False}
}])

CC @KieranBrantnerMagee @rakshith91

@lmazuel lmazuel added Event Grid Client This issue points to a problem in the data-plane of the library. labels Aug 7, 2020
@lmazuel lmazuel added this to the [2020] September milestone Aug 7, 2020
@rakshith91 rakshith91 mentioned this issue Aug 19, 2020
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-python that referenced this issue Mar 1, 2021
@lmazuel lmazuel added the Messaging Messaging crew label Apr 12, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. Event Grid Messaging Messaging crew
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants