Skip to content

Set Device Object To Optional - According to API Design Guidelines#298

Merged
jlurien merged 6 commits intocamaraproject:mainfrom
dfischer-tech:main
Feb 25, 2025
Merged

Set Device Object To Optional - According to API Design Guidelines#298
jlurien merged 6 commits intocamaraproject:mainfrom
dfischer-tech:main

Conversation

@dfischer-tech
Copy link
Contributor

What type of PR is this?

Add one of the following kinds:

  • correction

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #297

Changelog input

 release-note
 Update geofencing-subscriptions.yaml to make the Device object optional.

Additional documentation

None

@dfischer-tech dfischer-tech changed the title feat: update geofencing-subscriptions.yaml Set Device Object To Optional - According to API Design Guidelines Feb 15, 2025
bigludo7
bigludo7 previously approved these changes Feb 16, 2025
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.

LGTM

Copy link
Contributor

@maxl2287 maxl2287 left a comment

Choose a reason for hiding this comment

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

Thanks @dfischer-tech for raising up this PR!
Could you please also update the info.description by adding the information about how to identify the device from the access-token:

    # Identifying the device from the access token

    This API requires the API consumer to identify a device as the subject of the API as follows:
    - When the API is invoked using a two-legged access token, the subject will be identified from the optional `device` object, which therefore MUST be provided.
    - When a three-legged access token is used however, this optional identifier MUST NOT be provided, as the subject will be uniquely identified from the access token.

    This approach simplifies API usage for API consumers using a three-legged access token to invoke the API by relying on the information that is associated with the access token and was identified during the authentication process.

(see:

# Identifying the device from the access token
This API requires the API consumer to identify a device as the subject of the API as follows:
- When the API is invoked using a two-legged access token, the subject will be identified from the optional `device` object, which therefore MUST be provided.
- When a three-legged access token is used however, this optional identifier MUST NOT be provided, as the subject will be uniquely identified from the access token.
)

@maxl2287 maxl2287 added the Spring25 Meta-release Spring25 label Feb 17, 2025
maxl2287
maxl2287 previously approved these changes Feb 18, 2025
Copy link
Contributor

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

If we opted to remove device as required in the request, we would need to remove it as well in the event contents. schemas AreaLeft, AreaEntered, SubscriptionEnds, and probably add some guideline that device must not be included in the event if not explicitly provided in the request

@dfischer-tech
Copy link
Contributor Author

If we opted to remove device as required in the request, we would need to remove it as well in the event contents. schemas AreaLeft, AreaEntered, SubscriptionEnds, and probably add some guideline that device must not be included in the event if not explicitly provided in the request

Hi @jlurien,
Thank you for your review and comment.
The device is set to "optional" to prevent conflicts when it has already been identified via an access token (which would otherwise result in a 422 - UNNECESSARY_IDENTIFIER).
However, the device still needs to be identified; otherwise, a 422 - MISSING_IDENTIFIER error would occur, with the message:

"An identifier is not included in the request and the device or phone number identification cannot be derived from the 3-legged access token."

Therefore, we do not need to explicitly remove it from the event contents (schemas: AreaLeft, AreaEntered, SubscriptionEnds),
because it must be there/identified.

@maxl2287 maxl2287 self-requested a review February 18, 2025 20:58
@maxl2287 maxl2287 dismissed their stale review February 18, 2025 20:59

Clarification about the device needed

@maxl2287
Copy link
Contributor

maxl2287 commented Feb 18, 2025

@dfischer-tech

For a better understanding I would like to reference here as well to QualityOnDemand:

Note that the device object is defined as optional and will only to be returned if provided in createSession.
(https://github.com/camaraproject/QualityOnDemand/blob/r2.1/code/API_definitions/quality-on-demand.yaml#L502)

Means that we only would like to provide information about the device, if this was explicitly provided by the user.
Or in other words: only when a 2-legged-token was used and the device is required to be in the request-body then we have to add the device also in the:

  • $.config.subscriptionDetail of the response
  • $.data in the cloud-event

If we are dealing with a 3-legged-token I aggree with @jlurien that we also have to remove the mandatory device-object from the CloudEvent $.data

DeviceStatus is doing it the same to just provide the subscriptionId as an identifier:

    BasicDeviceEventData:
      description: Event detail structure for basic device events
      type: object
      required:
        - subscriptionId
      properties:
        device:
          $ref: "#/components/schemas/Device"
        subscriptionId:
          $ref: "#/components/schemas/SubscriptionId"

https://github.com/camaraproject/DeviceStatus/blob/r2.1/code/API_definitions/device-roaming-status-subscriptions.yaml#L934-L943

@dfischer-tech
Copy link
Contributor Author

@jlurien @maxl2287
Thank you for the notice – understood and accepted.

@maxl2287 maxl2287 requested a review from jlurien February 19, 2025 10:27
Copy link
Contributor

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

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

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.

@dfischer-tech , @maxl2287 The changes are OK, but we have to revert versions to wip and /vwip in the URL before merging (as in #303). At the same time, issue #302 could be fixed in this PR

@jlurien jlurien self-requested a review February 21, 2025 08:40
@maxl2287
Copy link
Contributor

@jlurien @bigludo7
Let's set back the versions via #305 first so we have a seperate PR for it.

@jlurien
Copy link
Collaborator

jlurien commented Feb 24, 2025

@jlurien @bigludo7 Let's set back the versions via #305 first so we have a seperate PR for it.

@dfischer-tech @maxl2287 already merged

@maxl2287
Copy link
Contributor

@jlurien @bigludo7 PR is now synced

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

@jlurien jlurien merged commit 33bf007 into camaraproject:main Feb 25, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Spring25 Meta-release Spring25

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Device Object Should Be Optional According to API Design Guidelines

4 participants