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

New API for location subscriptions #74

Conversation

chia2017
Copy link
Contributor

@chia2017 chia2017 commented Jul 4, 2023

What type of PR is this?

enhancement/feature

What this PR does / why we need it:

Create a new API for creating subscriptions for location based events

Which issue(s) this PR fixes:

This PR is related to issue #18 Subscription for Location Area

Fixes #

Special notes for reviewers:

Changelog input

 release-note

Additional documentation

This section can be blank.

docs

resolved review comments
removed extra boolean variables
Changed yaml file based on last review comments
Resolved review comments
…ptions-api-with-event-subscription-endpoint

Create location-subscriptions.yaml
@chia2017 chia2017 changed the title feat/create-new-location-subscriptions-api-for-creating-subscriptions-for-location-based-events feat/new-API-for-location-subscriptions Jul 4, 2023
@chia2017 chia2017 changed the title feat/new-API-for-location-subscriptions feat/New API for location subscriptions Jul 4, 2023
@chia2017 chia2017 changed the title feat/New API for location subscriptions New API for location subscriptions Jul 4, 2023
Copy link
Collaborator

@jlurien jlurien left a comment

Choose a reason for hiding this comment

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

It is very well aligned with Commonalities, so nothing to comment there.

  • Area and Circle models are being changed in another ongoing PR (fix/ location-verification: remodel-Area-inheritance #77). We will have to align there also here. We may discuss at this point if it makes sense to have a separated file with common schemas for Device and Area
  • I would allow to subscribe to both events, for same Device and Area, in the same subscription

code/API_definitions/location-subscriptions.yaml Outdated Show resolved Hide resolved
default: http://localhost:9091
description: API root
basePath:
default: location-subscription/v0
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have to choose a more specific name for this API, as in future we are likely to have another location subscription API for geotracking. This one is related to location verification or geofencing use case. There is an open issue to choose this name: #69
Once chosen, we have to align it here and also in title, descriptions, etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked at issue #69. It seems still this issue is open and you did not finalize the decision about naming. Once is finalized I can change the name of API.

Copy link
Collaborator

Choose a reason for hiding this comment

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

it seems that geofencing is the name with more consensus, so you can apply it

code/API_definitions/location-subscriptions.yaml Outdated Show resolved Hide resolved
Copy link
Collaborator

@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.

Thanks a lot !
Few comments.
Main one is to have a common CAMARA decision on using callback or specific endpoint. Both works but my developer feedback told me that callback did not work well with code generator.
We need also alignment on subscription starts/expires date.

code/API_definitions/location-subscriptions.yaml Outdated Show resolved Hide resolved
code/API_definitions/location-subscriptions.yaml Outdated Show resolved Hide resolved
code/API_definitions/location-subscriptions.yaml Outdated Show resolved Hide resolved
code/API_definitions/location-subscriptions.yaml Outdated Show resolved Hide resolved
code/API_definitions/location-subscriptions.yaml Outdated Show resolved Hide resolved
code/API_definitions/location-subscriptions.yaml Outdated Show resolved Hide resolved
code/API_definitions/location-subscriptions.yaml Outdated Show resolved Hide resolved
schema:
$ref: '#/components/schemas/CreateEventSubscription'
required: true
callbacks:
Copy link
Collaborator

Choose a reason for hiding this comment

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

We did not have right now a decision for using call back or providing a standard endpoint for Notification.
There is is an issue in commonalities to discuss this camaraproject/Commonalities#8

Copy link
Collaborator

@jlurien jlurien left a comment

Choose a reason for hiding this comment

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

Need to define the eventDetail for the events to be notified

code/API_definitions/location-subscriptions.yaml Outdated Show resolved Hide resolved
code/API_definitions/location-subscriptions.yaml Outdated Show resolved Hide resolved
Please check this last commit. All the review comments applied.
@jlurien
Copy link
Collaborator

jlurien commented Jul 13, 2023

@chia2017 you still have to define the details in the specific events being notified, that is the device and area.

        eventDetail:
          type: object -> here instead of object


Event:
description: The event being notified
anyOf:
Copy link
Collaborator

Choose a reason for hiding this comment

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

There was a discussion in QoD to favour allOf vs anyOf to model the event, due to better compatibility with some generators and coding languages, you can check the PR here: camaraproject/QualityOnDemand#177

This was proposed by Orange, @bigludo7

@jlurien jlurien self-requested a review July 14, 2023 09:48
Deleted EventBase object, now all other events inherit from Event object and there is no "anyOf" in the Event anymore
description: |
AREA_ENTERED - Location event triggered when the device entered the given area
AREA_LEFT - Location event triggered when the device left the given area
SUBSCRIPTION_ENDS - It is inform listener request that subscription terminates.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@bigludo7 Here we are adding SUBSCRIPTION_ENDS event in the operation to create a subscription and I was checking yesterday's PR from Device Status and we didn't add it there: https://github.com/camaraproject/DeviceStatus/blob/main/code/API_definitions/device-status.yaml#L513

should we align this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@fernandopradocabrillo Interesting point to discuss.

In device status API we have SUBSCRIPTION_ENDS event but you not have to manage a subscription for this. We consider this is 'automatically' triggered for all notification. When the notification subscription ends, the event is sent.

Here by adding it in the subscription, it means that it required a voluntary action by the developer.

I tend to prefer the approach in device status API but we absolutely need a consensus on this to have same approach in all API.

Copy link
Collaborator

@jlurien jlurien Jul 18, 2023

Choose a reason for hiding this comment

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

Really, I think it makes no sense to allow a subscription to SUBSCRIPTION_ENDS event, as this event is triggered when a subscription to another event ends

Copy link
Contributor

Choose a reason for hiding this comment

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

I also think that we don't need that event in the create-subscription, but in the event-notification

Copy link
Contributor Author

@chia2017 chia2017 Jul 24, 2023

Choose a reason for hiding this comment

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

I updated the yaml file , please also see the commit's comment.

Create EventTypeNotification which inherit from EventType, now in create subscription we do not have SUBSCRIPTION_ENDS and only in notification we use that.
Copy link
Collaborator

@jlurien jlurien left a comment

Choose a reason for hiding this comment

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

A new adhoc enum with the 3 values have to be defined

EventTypeNotification:
description: |
Event type used in event notification
allOf:
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 not correct. allOf is not extending the enum, it just requires that the object validated against the schema is compliant with all of the sub-schemas, and it cannot comply with both enum at the same time. You have to define an enum with the 3 allowed values for the NotifiedEventType.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yaml file is updated.

Created NotifiedEventType enum with 3 values
jlurien
jlurien previously approved these changes Jul 27, 2023
Copy link
Collaborator

@jlurien jlurien left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@jlurien jlurien left a comment

Choose a reason for hiding this comment

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

Rename api to geofencing

default: http://localhost:9091
description: API root
basePath:
default: location-subscription/v0
Copy link
Collaborator

Choose a reason for hiding this comment

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

it seems that geofencing is the name with more consensus, so you can apply it

@jlurien jlurien requested review from jlurien and bigludo7 July 27, 2023 12:37
change the api name to geofencing
changed the title and description of API based on new name
@chia2017
Copy link
Contributor Author

Rename api to geofencing

Hi, I renamed the api two weeks ago before I went to vacation. So I did not recieve any new comment about review, If you think everything is fine you can merge this PR, but first it need two approvers. Anyway I am available if you have any comment.
Best,
Sadeghi

Copy link
Collaborator

@jlurien jlurien left a comment

Choose a reason for hiding this comment

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

Add auth2 scopes, some renaming to geofencing

openapi: 3.0.3
info:
title: Device geofencing API
description: Service Enabling Network Function API to create, retrieve and delete event subscriptions to realize geofencing for a user device
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
description: Service Enabling Network Function API to create, retrieve and delete event subscriptions to realize geofencing for a user device
description: API to create, retrieve and delete event subscriptions to realize geofencing for a user device

This has been deprecated to avoid using 3GPP terminology. Anyway, API doc has to be improved after merge

url: https://github.com/camaraproject/
security:
- oAuth2ClientCredentials: []
- three_legged: []
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- three_legged: []

We can remove this at global level add security per operation with dedicated scopes

description: API root
basePath:
default: geofencing/v0
description: Base path for the device location subscription API
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
description: Base path for the device location subscription API
description: Base path for the device geofencing API

'500':
$ref: '#/components/responses/Generic500'
'503':
$ref: '#/components/responses/Generic503'
Copy link
Collaborator

@jlurien jlurien Aug 14, 2023

Choose a reason for hiding this comment

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

Suggested change
$ref: '#/components/responses/Generic503'
$ref: '#/components/responses/Generic503'
security:
- oAuth2AuthorizationCode:
- "geofencing:subscriptions:write"

'500':
$ref: '#/components/responses/Generic500'
'503':
$ref: '#/components/responses/Generic503'
Copy link
Collaborator

@jlurien jlurien Aug 14, 2023

Choose a reason for hiding this comment

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

Suggested change
$ref: '#/components/responses/Generic503'
$ref: '#/components/responses/Generic503'
security:
- oAuth2AuthorizationCode:
- "geofencing:subscriptions:read"

$ref: '#/components/responses/Generic503'
get:
tags:
- Location Event Subscription
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- Location Event Subscription
- Geofencing

/event-subscriptions/{eventSubscriptionsId}:
get:
tags:
- Location Event Subscription
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- Location Event Subscription
- Geofencing

$ref: '#/components/responses/Generic503'
delete:
tags:
- Location Event Subscription
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- Location Event Subscription
- Geofencing

'500':
$ref: '#/components/responses/Generic500'
'503':
$ref: '#/components/responses/Generic503'
Copy link
Collaborator

@jlurien jlurien Aug 14, 2023

Choose a reason for hiding this comment

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

Suggested change
$ref: '#/components/responses/Generic503'
$ref: '#/components/responses/Generic503'
security:
- oAuth2AuthorizationCode:
- "geofencing:subscriptions:read"

post:
tags:
- Location Event Subscription
summary: 'Create a location event subscription for a device'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
summary: 'Create a location event subscription for a device'
summary: 'Create a geofencing event subscription for a device'

@jlurien
Copy link
Collaborator

jlurien commented Aug 14, 2023

Rename api to geofencing

Hi, I renamed the api two weeks ago before I went to vacation. So I did not recieve any new comment about review, If you think everything is fine you can merge this PR, but first it need two approvers. Anyway I am available if you have any comment. Best, Sadeghi

Hi Sadeghi. I made another review. I think it is almost ready. Once @bigludo7 is back and make a further check we can merge. Thanks!

@bigludo7
Copy link
Collaborator

@chia2017 @jlurien Thanks for the effort - It looks good for me and thanks to have fixed my previous comments. Once José comments resolved we should be good for merging

@chia2017
Copy link
Contributor Author

I updated the API and applied all last comments that you wrote. If you have no more comment you can merge it and we can close the task. If you have further request you can contact my colleague Maximilian Laue, since I am not working with this project and I switched to the new project.
Best,
Sadeghi

@maxl2287
Copy link
Contributor

maxl2287 commented Sep 8, 2023

I updated the API and applied all last comments that you wrote. If you have no more comment you can merge it and we can close the task. If you have further request you can contact my colleague Maximilian Laue, since I am not working with this project and I switched to the new project. Best, Sadeghi

@bigludo7 & @jlurien:

Could you please review again.
When anything needs to be adapted then I will fix it asap.

Thanks! 🚀

@bigludo7
Copy link
Collaborator

bigludo7 commented Sep 8, 2023

Thanks @chia2017 for the effort and good luck for your new project
@maxl2287 As of now we cannot approve because following DT suggestion (and CAMARA team approval) the event notification should be aligned with the CloudEvents.
This update is describe here: camaraproject/Commonalities#56 and right now is in team review.

My recommendation is to wait for approval before to adjust your code.
Thanks

@jlurien
Copy link
Collaborator

jlurien commented Oct 2, 2023

Now that camaraproject/Commonalities#56 has been merged, we should update this PR accordingly @maxl2287, @akoshunyadi. Thanks

@maxl2287
Copy link
Contributor

maxl2287 commented Oct 9, 2023

I created PR #98 to align on CloudEvents based on these commits here.
In the fact that @chia2017 is not part of the CAMARA project anymore and I am not allowed to add commits to his repository.

@bigludo7
Copy link
Collaborator

This feature is now followed here: #98

@bigludo7 bigludo7 closed this Oct 10, 2023
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.

6 participants