-
Notifications
You must be signed in to change notification settings - Fork 29
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
Define CAMARA Event using cloudevents in OAS notification #43
Conversation
… specifications fix camaraproject#8 Signed-off-by: Patrice Conil <[email protected]>
Thank you @patrice-conil for this input, it is good starting point to evaluate Cloudevents (CE) for event notification format. source
type
subject
Let's wait for evaluation and feedback from subprojects interested in Event notification. |
Hi @rartych,
I think it should refer to the specific vendor implementation, i.e. the context in which the fact occurred
I think reverse DNS here is used to include package name with type to have fully qualified class name of the event type. Of course to have same reference for same type in all implementations we should use something like org.camara.api.qod.QosStatusChangedEvent
It's open to discussion.
|
…subject' as a subscription topic Signed-off-by: Patrice Conil <[email protected]>
description: | | ||
Events received on subscription listener side. | ||
paths: | ||
/notifications: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the name contain 'cloudevent'? Currently the name is general but the description is cloudevent-specific
$ref: '#/components/schemas/Source' | ||
type: | ||
type: string | ||
description: 'type of event as defined in each CAMARA API (examples: ROAMING_STATUS, QOS_STATUS_CHANGED, PAYMENT_COMPLETED, etc...)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use, as in request example, a fully qualified class name as type. The cloudevents spec also suggests to use a version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…t to cloudevents Signed-off-by: Patrice Conil <[email protected]>
Signed-off-by: Patrice Conil <[email protected]>
5a1f11a
to
e2418d3
Compare
I think we will also need the property dataschema, otherwise how could the consumer process the data? |
dataschema is optional attribute, so it is not needed to send it with events. |
Hi @rartych, @akoshunyadi, |
@patrice-conil yes, but this spec doesn't contain any specific event details. And if we add a cloudevents subscription API that one is also generic. So we need a place for the definition of specific events, which we can do with inheritance from CloudEvent. |
Hi @akoshunyadi, |
The CloudEvent example should be aligned with the final decisions on the content of each attribute in PR #56 |
description: | | ||
Events received on subscription listener side. | ||
paths: | ||
/cloudevents: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same coment as: #41 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
- CAMARA Cloud Event notification endpoint | ||
summary: "Cloud Event notification endpoint to notify consumer that statement of fact had occurred" | ||
description: Cloud Event notification endpoint to notify consumer that statement of fact occurred. This endpoint must be exposed on the consumer side. | ||
operationId: notifyCloudEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imho, I would set a name "transparent" to the underlying model
|
||
# API Functionality | ||
|
||
Only one endpoint/operation is provided: `POST /cloudevents` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to align with paths design, think we need to rename to:
POST /your_webhook_notificationUrl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
license: | ||
name: Apache 2.0 | ||
url: https://www.apache.org/licenses/LICENSE-2.0.html | ||
version: 0.5.0-wip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When agreed (just doubt):
- Do we set initially to v0.5.0 (removing wip), doesn't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set to 0.1.0
Co-authored-by: Pedro Díez García <[email protected]>
Co-authored-by: Pedro Díez García <[email protected]>
Signed-off-by: Patrice Conil <[email protected]> Signed-off-by: Patrice Conil <[email protected]>
Signed-off-by: Patrice Conil <[email protected]>
type: string | ||
format: uri-reference | ||
minLength: 1 | ||
description: "Identifies the context in which an event happened - be a non-empty `URI-reference." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closing backtick for URI-reference
description: "Identifies the context in which an event happened - be a non-empty `URI-reference." | |
description: "Identifies the context in which an event happened - be a non-empty `URI-reference`." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Signed-off-by: Patrice Conil <[email protected]>
QOS_STATUS_CHANGED_EXAMPLE: | ||
value: | ||
id: "123e4567-e89b-12d3-a456-426655440000" | ||
source: "com.orange.camara.qod" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example of Absolute URI in source
attribute:
source: "com.orange.camara.qod" | |
source: https://notificationSendServer12.supertelco.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Signed-off-by: Patrice Conil <[email protected]>
Signed-off-by: Patrice Conil <[email protected]>
Co-authored-by: Rafal Artych <[email protected]>
description: Event details payload described in each CAMARA API and referenced by its type | ||
time: | ||
$ref: "#/components/schemas/DateTime" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make the template even more useful, I would add also a sample schema for children events something like:
ChildEventWithData:
allOf:
- $ref: "#/components/schemas/CloudEvent"
- type: object
properties:
data:
type: object
description: Event details depending on the event type
properties: {}
required: {}
required:
- data
* 1-555-123-4567 | ||
example: "https://notificationSendServer12.supertelco.com" | ||
|
||
CloudEvent: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also add a discriminator explicitly to this base class schema
discriminator:
propertyName: type
mapping:
CHILD_EVENT_NAME: "#/components/schemas/ChildEventWithData"
``
datacontenttype: | ||
type: string | ||
description: 'media-type that describes the event payload encoding, must be "application/json" for CAMARA APIs' | ||
data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a discussion in camaraproject/QualityOnDemand#224 (comment), about whether 1) to define data
in the base class, as optional and with a generic type: object
, or 2) to define data
only in the child events which has data. Both would be correct, but not sure about which one would work better with code generators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not have experience with code generators, but currently we do not have any example of subproject using events without data
object. So for simplicity I prefer approach 1) where we do not have to define child object ChildEventWithData
in each subproject using eventing, but data
is in base class as optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed for that reason we have to define "a ChildEventWithData" schema, including data
for each Child event. The name is just a templated one, real names we already have, among others:
QoD:
EventQosStatusChanged:
allOf:
- $ref: "#/components/schemas/CloudEvent"
- type: object
properties:
data: {}
DeviceStatus:
EventRoamingStatus:
description: event structure for roaming status change
allOf:
- $ref: "#/components/schemas/CloudEvent"
- type: object
properties:
data:
$ref: "#/components/schemas/RoamingStatus"
EventRoamingOn:
description: event structure for roaming on change
allOf:
- $ref: "#/components/schemas/CloudEvent"
- type: object
properties:
data:
$ref: "#/components/schemas/BasicDeviceEventData"
so we have to define the data per child event mandatorily always. The question was whether we should have to define it also in the base schema as optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jlurien, I agree with you, from an OO perspective we don't need to define it in the base schema.
I'm undecided because optional data field can also be considered a placeholder for what to extend in child classes.
But as you are the first that use this template in QoD and don't find it so useful, I will remove it from base class.
@rartych, both versions works with code generators.
I think defining ChildEventWithData add unnecessary layer in model, I just added a comment in CloudEvent description. WDYT about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far, it is kept as optional in the CloudEvent base class. I think this is what get more consensus. If both work well with code generators, they are totally equivalent and the final schema once the composition is applied is the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with both approaches. API Design Guidelines are "normative" for CAMARA, here we provide example that can be used by subprojects and API Consumers, but other definitions can be used if they conform to API Design Guidelines and CloudEvents specification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see: #43 (comment)
requestBody: | ||
required: true | ||
content: | ||
application/cloudevents+json: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is correct but I think someone complained about lack of support by certain code generators. We could stick to just application/json
if it is safer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to CloudEvents discussion format of "+json" is defined in RFC6839, so it should be supported by code generators.
I propose to follow the CloudEvents requirement for JSON format:
Such a representation MUST use the media type
application/cloudevents+json
Co-authored-by: Rafal Artych <[email protected]>
Signed-off-by: Patrice Conil <[email protected]>
@jlurien @patrice-conil Can we finalize still open points and go with final review, to be ready for Commonalities 0.2.0 release? |
I see that you finally have removed |
…oudEvent Signed-off-by: Patrice Conil <[email protected]>
Hi @jlurien, Commit reverted to keep data as optional field. |
Hi @rartych, |
Thanks @patrice-conil . @jlurien @PedroDiez @RubenBG7 @jordonezlucena Could you approve this PR, so we can be ready for release 0.2.0? |
will review today |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/LGTM
What type of PR is this?
What this PR does / why we need it:
This PR increase interoperability between our ecosystem and rest of world using a defacto standard
Which issue(s) this PR fixes:
Fixes #8
Special notes for reviewers:
BREAKING CHANGES:
Changelog input
Additional documentation