Skip to content

Added Notification management aligned with CloudEvents format#75

Merged
bigludo7 merged 16 commits intomainfrom
bigludo7-patch-4
Nov 8, 2023
Merged

Added Notification management aligned with CloudEvents format#75
bigludo7 merged 16 commits intomainfrom
bigludo7-patch-4

Conversation

@bigludo7
Copy link
Collaborator

@bigludo7 bigludo7 commented Sep 27, 2023

What type of PR is this?

  • enhancement/feature

What this PR does / why we need it:

Aligned with CloudEvents format as defined in Commonalities here: camaraproject/Commonalities#56

Which issue(s) this PR fixes:

Fixes #74 #57

Special notes for reviewers:

Changelog input

- Provide roaming status subscription & notification aligned with Cloudevents structure.

Additional documentation

This section can be blank.

docs

Aligned with CloudEvents format
@akoshunyadi
Copy link
Collaborator

@bigludo7 This PR fixes also Issue #57 ?

@bigludo7
Copy link
Collaborator Author

bigludo7 commented Sep 28, 2023

@bigludo7 This PR fixes also Issue #57 ?

@akoshunyadi correct ! - fixed.

Copy link
Collaborator Author

@bigludo7 bigludo7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aligned with merged DG for event & subscriptions
@akoshunyadi @sachinvodafone

requestBody:
required: true
content:
application/json:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to use application/cloudevents+json as stated in
https://github.com/cloudevents/spec/blob/main/cloudevents/formats/json-format.md#3-envelope

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlurien Yes make sense.
I will apply.

Do you think we need to go on this detail in the design guideline document as well? I tend to think yes.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I think it will be useful to add this and maybe provide a template or artifact as example. I learned about this from some @patrice-conil 's PR indeed

Changed to 
content:
                  application/cloudevents+json
Copy link
Collaborator Author

@bigludo7 bigludo7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed content: application/json to content: application/cloudevents+json for alignement with CloudEvents specification

summary: 'Create a device status event subscription for a device'
description: Create a device status event subscription for a device
operationId: createDevicStatusEventSubscription
operationId: createDevicStatusSubscription
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo:
createDeviceStatusSubscription

Comment on lines +656 to +659
- id
- source
- specversion
- type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"time" is missing as required.

See Commonalities:

Note: Attribute time is tagged as optional in CloudEvents specification but from CAMARA perspective we mandate to value this attributes.

https://github.com/camaraproject/Commonalities/blob/main/documentation/API-design-guidelines.md#event-notification-definition

roaming: true
countryCode: 208
countryName: FR
roaming: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the document, it's mentioned that "The event subscription identifier must have a value when dealing with Resource-based subscriptions." So we should include the "subscriptionId" in the callback response if it's relevant or applicable in that context.

Took into account  team review requests
Copy link
Collaborator Author

@bigludo7 bigludo7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took @maxl2287 and @sachinvodafone review comments into account;
Thanks for the review.


API consumer is able to verify whether a certain user device is in roaming situation (or not). This capability is provided in 2 ways:
- via direct request with the roaming situation in the response.
- via a subscription request - in this case the roaming situation is not in the response but event notification is sent back to the event subscriber when roaming situation change.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: change => changed or has changed


## Device status subscription

Theses endpoints allow to manage event subscription on roaming device status event.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: theses => these

- ``org.camaraproject.device-status.v0.roaming-change-country``: Event triggered when the device in roaming change country code

Note: Additionnally to these list, ``org.camaraproject.device-status.v0.subscription-ends`` notification `type` is sent when the subscription ends.
This notification did not requires dedicated subscription.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: did not requires => does not require

schema:
$ref: "#/components/schemas/CloudEvent"
examples:
ROAMING_STATUS:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to keep these old constants, since they are not used for the type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the constant name to be closer to the type but I kept only the significant part;

type: string
description: |
ROAMING_STATUS - Event triggered when the device switch from roaming ON to roaming OFF and conversely
roaming-status - Event triggered when the device switch from roaming ON to roaming OFF and conversely
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to use SubscriptionType or SubscriptionEventType instead of RoamingEventType.

  • to better distinguish between subscription event type and notification event type
  • as a preparation for other type of events


EventRoamingOff:
description: event structure for roaming on and roaming off change
description: event structure for roaming on and roaming off change
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only for roaming off

RoamingStatus:
description: Event detail structure for ROAMING_STATUS event
type : object
type: object
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no ROAMING_STATUS event anymore

RoamingChange:
description: Event detail structure for ROAMING_ON & ROAMING_OFF event
type : object
type: object
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no ROAMING_ON and ROAMING_OFF events anymore

SubscriptionEnds:
description: Event detail structure for SUBSCRIPTION_ENDS event
type : object
type: object
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no SUBSCRIPTION_ENDS event

RoamingChangeCountry:
description: Event detail structure for ROAMING_CHANGE_COUNTRY event
type : object
type: object
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no ROAMING_CHANGE_COUNTRY event

Took into account @akoshunyadi review comments.
Copy link
Collaborator Author

@bigludo7 bigludo7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took into account @akoshunyadi review comments.

schema:
$ref: "#/components/schemas/CloudEvent"
examples:
ROAMING_STATUS:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the constant name to be closer to the type but I kept only the significant part;

Copy link
Collaborator

@fernandopradocabrillo fernandopradocabrillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bigludo7
Sorry I didn't review before. I leave here a comment regarding the scopes. This is a topic that was raised in Sim swap too, regarding in terms of privacy what scopes should we use for each operation. For example, I might be able to read the roaming status but maybe not to create a subscription, but on the other hand, I should not be able to create a subscription if I don't have permission to read the roaming status

Comment on lines +87 to +88
- device-status:roaming:read
- device-status:roaming-event-subscriptions:create
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are we going to manage the scopes for the subscriptions? I can see that we have an scope for creating subscriptions but I think we are missing an additional scope to delete subscriptions too. And, in order to retrieve the available subscriptions, are we going to use the same scope as we use to read the roaming status?

Suggested change
- device-status:roaming:read
- device-status:roaming-event-subscriptions:create
- device-status:roaming:read
- device-status:roaming-event-subscriptions:read
- device-status:roaming-event-subscriptions:create
- device-status:roaming-event-subscriptions:delete

Whether we decide to use specific scopes or not, we should use the security property for each individual operation because right now, using the global property some operations don't have a correct scope. For example we have a create scope for a delete operation:

image

$ref: '#/components/responses/Generic503'
/event-subscriptions/{eventSubscriptionId}:
$ref: "#/components/responses/Generic503"
/subscriptions/{subscriptionId}:
Copy link
Collaborator

@sachinvodafone sachinvodafone Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems, we have missed to define valid security scope for get/delete subscription operation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

503:
$ref: '#/components/responses/Generic503'
$ref: "#/components/responses/Generic503"
get:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No valid security scope to "list" subscriptions (get operation)

$ref: '#/components/schemas/RoamingStatusResponse'
$ref: "#/components/schemas/RoamingStatusResponse"
examples:
No-Country-Code:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it example of "No-Country-Code" or "No-Country-Name"
Screenshot 2023-10-25 at 12 12 06

@sachinvodafone
Copy link
Collaborator

In some responses, we are having missing "status":
Screenshot 2023-10-25 at 12 29 30

@sachinvodafone
Copy link
Collaborator

What kind of response can the client anticipate when they receive a subscription ID in a 202 response code (asynchronous process) and attempt to access /subscriptions/{subscriptionId} where process is still not completed ?

  1. 202 Accepted (Still Processing):
  2. 404 Not Found (Subscription ID Not Found)
Screenshot 2023-10-25 at 12 43 57

@bigludo7
Copy link
Collaborator Author

What kind of response can the client anticipate when they receive a subscription ID in a 202 response code (asynchronous process) and attempt to access /subscriptions/{subscriptionId} where process is still not completed ?

  1. 202 Accepted (Still Processing):
  2. 404 Not Found (Subscription ID Not Found)
Screenshot 2023-10-25 at 12 43 57

Good question and probably should tackled in a larger extend than this API. I will imagine 202 is a better option.

Copy link
Collaborator Author

@bigludo7 bigludo7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated following @sachinvodafone and @fernandopradocabrillo review

@sachinvodafone
Copy link
Collaborator

What kind of response can the client anticipate when they receive a subscription ID in a 202 response code (asynchronous process) and attempt to access /subscriptions/{subscriptionId} where process is still not completed ?

  1. 202 Accepted (Still Processing):
  2. 404 Not Found (Subscription ID Not Found)
Screenshot 2023-10-25 at 12 43 57

Good question and probably should tackled in a larger extend than this API. I will imagine 202 is a better option.

So in this scenario, we must have 202 in response code against "/subscriptions/{subscriptionId}"

Copy link
Collaborator Author

@bigludo7 bigludo7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed typo for error 500 (Thanks @sachinvodafone )

Added 202 for GET /subscriptions/{subscriptionId} as suggested by @sachinvodafone
Copy link
Collaborator Author

@bigludo7 bigludo7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added 202 for GET /subscriptions/{subscriptionId} as suggested by @sachinvodafone

sachinvodafone
sachinvodafone previously approved these changes Oct 30, 2023
@bigludo7
Copy link
Collaborator Author

bigludo7 commented Oct 30, 2023

Thanks @sachinvodafone for the approval;
@akoshunyadi and @fernandopradocabrillo looking also for your approval or comments. Your are not 'formal code owners but as you provided comments I'l also looking for your approval. Thanks

@fernandopradocabrillo
Copy link
Collaborator

fernandopradocabrillo commented Oct 30, 2023

What kind of response can the client anticipate when they receive a subscription ID in a 202 response code (asynchronous process) and attempt to access /subscriptions/{subscriptionId} where process is still not completed ?

  1. 202 Accepted (Still Processing):
  2. 404 Not Found (Subscription ID Not Found)
Screenshot 2023-10-25 at 12 43 57

Good question and probably should tackled in a larger extend than this API. I will imagine 202 is a better option.

So in this scenario, we must have 202 in response code against "/subscriptions/{subscriptionId}"

I'm not really sure a 202 is the best option to return. If I create a subscription, receive a 202 and request the info before it is created, the subscription hasn't been created yet so I'd say it is better a 404.

I haven't seen a 202 in a GET, it is a bit weird. I think it adds complexity to the implementation because the response may vary if I make the call and receive a 202 and 5mins later I receive a 200 with the info, this does not happen with the POST/PUT operations since you only make the call once. And this will force the backend to have some way of tracking the process of creating the subscription to know what to return depending on the moment.

IMO I think it is more common to return a 404 and when the subscription is created, return the 200.

cc: @bigludo7 @sachinvodafone

operationId: createDeviceStatusSubscription
security:
- openId:
- device-status:roaming-subscriptions:create
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a generic operation to create a subscription as the endpoint, description, operationId say, so I think also the scope shouldn't contain "roaming".

Similar for other subscription operations too.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

Copy link
Collaborator Author

@bigludo7 bigludo7 Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akoshunyadi Yes make sense. Fixed. I've kept device-status as prefix.

Remove 202 for GET following @fernandopradocabrillo  comment.
Rename scope Following @akoshunyadi comment
Copy link
Collaborator Author

@bigludo7 bigludo7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove 202 for GET following @fernandopradocabrillo comment.
Rename scope for subscription operation following @akoshunyadi comment

@bigludo7
Copy link
Collaborator Author

bigludo7 commented Nov 2, 2023

What kind of response can the client anticipate when they receive a subscription ID in a 202 response code (asynchronous process) and attempt to access /subscriptions/{subscriptionId} where process is still not completed ?

  1. 202 Accepted (Still Processing):
  2. 404 Not Found (Subscription ID Not Found)
Screenshot 2023-10-25 at 12 43 57

Good question and probably should tackled in a larger extend than this API. I will imagine 202 is a better option.

So in this scenario, we must have 202 in response code against "/subscriptions/{subscriptionId}"

I'm not really sure a 202 is the best option to return. If I create a subscription, receive a 202 and request the info before it is created, the subscription hasn't been created yet so I'd say it is better a 404.

I haven't seen a 202 in a GET, it is a bit weird. I think it adds complexity to the implementation because the response may vary if I make the call and receive a 202 and 5mins later I receive a 200 with the info, this does not happen with the POST/PUT operations since you only make the call once. And this will force the backend to have some way of tracking the process of creating the subscription to know what to return depending on the moment.

IMO I think it is more common to return a 404 and when the subscription is created, return the 200.

cc: @bigludo7 @sachinvodafone

OK!
I guess need extra discussion for adding 202 for GET when we have potentially ASYNC creation. As this topic is larger to this API I have removed the 202 and adding this point here: camaraproject/Commonalities#83
@sachinvodafone hope it's ok for you.

bigludo7 and others added 7 commits November 8, 2023 11:01
Co-authored-by: Rafal Artych <121048129+rartych@users.noreply.github.com>
Co-authored-by: Rafal Artych <121048129+rartych@users.noreply.github.com>
Co-authored-by: Rafal Artych <121048129+rartych@users.noreply.github.com>
Co-authored-by: Rafal Artych <121048129+rartych@users.noreply.github.com>
Co-authored-by: Rafal Artych <121048129+rartych@users.noreply.github.com>
Co-authored-by: Rafal Artych <121048129+rartych@users.noreply.github.com>
Co-authored-by: Rafal Artych <121048129+rartych@users.noreply.github.com>
@bigludo7 bigludo7 merged commit f378921 into main Nov 8, 2023
@bigludo7 bigludo7 deleted the bigludo7-patch-4 branch November 8, 2023 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align event-subscriptions with updated design guidelines based on CloudEvents

7 participants