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

Update resource.json #2798

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update resource.json #2798

wants to merge 1 commit into from

Conversation

MCFurry
Copy link

@MCFurry MCFurry commented Sep 11, 2023

Updating a device_tag via the documented API, changed ALL tags to the new value. The proposed change does what it actually is supposed to do.


Please make sure to read the CONTRIBUTING document before opening the PR for relevant information on contributing to the documentation. Thanks!

Updating a device_tag via the documented API, changed ALL tags to the new value.
The proposed change does what it actually is supposed to do.
@thgreasi
Copy link
Member

thgreasi commented Oct 20, 2023

Hi @MCFurry ,
Thanks for raising this.
Can you provide the exact curl that you used?
I'm afraid that the $filter part was incorrectly escaped.
For example the following curl (changed to a GET so that there is no hesitation while testing it) returns exactly one tag for me, while I do have more devices with the same & other tags.

curl -X GET "https://api.balena-cloud.com/v6/device_tag?\$filter=(tag_key%20eq%20'stats.last_application_start')%20and%20(device%20eq%2012506355)" -H  "Content-Type: application/json"  -H "Authorization: Bearer <...>"

@thgreasi
Copy link
Member

Could you please amend your commit (not the PR description) and add a Change-type: patch at the end of it so that our CI system is able to version & merge your PR?

@@ -543,8 +543,7 @@
"summary": "Update a device tag",
"description": "",
"method": "PATCH",
"endpoint": "/v6/device_tag",
"filters": "?\\$filter=(tag_key%20eq%20'<EXISTING-KEY>')%20and%20(device%20eq%20<DEVICE_ID>)",
"endpoint": "/v6/device_tag(<TAG-ID>)",
Copy link
Member

Choose a reason for hiding this comment

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

Optional-idea: As an additional/alternative suggestion, it might be more convenient to suggest using the composite ID notation, which is also save against unescaped $filters.

Suggested change
"endpoint": "/v6/device_tag(<TAG-ID>)",
"endpoint": "/v6/device_tag(device=<DEVICE_ID>,tag_key='<EXISTING-KEY>'",

If you prefer having the numeric ID variant as well, but also like my suggestion you can add it as a separate example by coping the current one and using a different id and summary.
Eg: "id": "update-tag-by-natural-key", "summary": "Update a device tag by device id and tag_key"

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.

None yet

2 participants