Skip to content

Commit

Permalink
update_label can now accept multiple objects
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbruder committed Jan 31, 2024
1 parent d59aae3 commit f03a61b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions update_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ def update_label():

while True:
object_search_again = False
object_id = input("Enter the ID of the object you want to " + update_action + " (or 's' to do another search): ")
if object_id.lower() == 's':
object_ids_input = input("Enter the IDs of the objects you want to " + update_action + " (comma-separated, or 's' to do another search): ")
if object_ids_input.lower() == 's':
object_search_again = True
break # Break the inner loop to go back to the start of the outer loop
try:
object_id = int(object_id)
object_ids = [int(object_id.strip()) for object_id in object_ids_input.split(',')]
break
except ValueError:
print("Invalid input. Please enter a number.")
Expand All @@ -110,12 +110,14 @@ def update_label():
objects = [{"dashboardId": obj['dashboardId']} for obj in label['dashboards']]

if update_action == 'add':
if object_type in ['tests', 'endpoint-tests']:
objects.append({'testId': object_id})
else:
objects.append({'agentId': object_id})
for object_id in object_ids:
if object_type in ['tests', 'endpoint-tests']:
objects.append({'testId': object_id})
else:
objects.append({'agentId': object_id})
else:
objects = [obj for obj in objects if list(obj.values())[0] != object_id]
for object_id in object_ids:
objects = [obj for obj in objects if list(obj.values())[0] != object_id]

data = {
'name': label['name'], # Include the label name in the request body
Expand Down

0 comments on commit f03a61b

Please sign in to comment.