Hello Friends!
I’m making some device management with Python. It came to my attention that there is no “Remove Tag” API endpoint option.
Once applied tags to an device via API call, how do I remove them later on?
Here is my implementation how to apply tags:
def apply_tag(self, tags):
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {self.pat}'
}
tag_list = list()
for key, value in tags.items():
tag_list.append({
"name": key,
"value": value
})
endpoint = f"{self.url}/api/management/v1/inventory/devices/{self.id}/tags"
response = requests.patch(endpoint, \
headers=headers, \
data=json.dumps(tag_list), \
timeout=10)
if response.status_code == 200:
return True
else:
print(f"Could not apply tags to device {self.id}, {self.serial}")
print(f"HTTP response: {response.status_code}")
print(f"API text: \n {response.text}")
print(f"API reason: \n {response.reason}")
return False
Can I utilise “Assign Tags” to remove tags?
What is the difference between “Assign” and “Apply”?
Thanks Everyone!