Skip to content

Commit 8bbd2ac

Browse files
committed
Add check_device_tag() method
Added a method to check if a device (defined either by DeviceID or DeviceUUID) has a given tag (defined by TagID) already applied.
1 parent b7f630b commit 8bbd2ac

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pyws1uem/mdm/tags.py

+19
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,22 @@ def remove_device_tag(self, tag_id: str, device_id: str):
5757
}
5858
response = MDM._post(self, path=path, json=device_to_add)
5959
return response
60+
61+
def check_device_tag(self, tag_id: str, device_id: str = None, device_uuid: str = None):
62+
"""Get a list of devices for the given tags and check
63+
if a specific device, defined by it's UUID, has the tag already assigned
64+
65+
Args:
66+
tag_id (str): The ID of the Tag in WorkspaceOneUEM
67+
device_id (str): The DeviceID of the Device in WorkspaceOneUEM (default: None)
68+
device_uuid (str): The UUID of the Device in WorkspaceOneUEM (default: None)
69+
70+
Returns:
71+
[bool]: True if the tag is assigned / False if not
72+
"""
73+
path = f'tags/{tag_id}/devices'
74+
response = MDM._get(self, path=path)
75+
for device in response['Device']:
76+
if str(device['DeviceId']) == device_id or device['DeviceUuid'] == device_uuid:
77+
return True
78+
return False

0 commit comments

Comments
 (0)