Skip to content

Commit

Permalink
fix: bugs with stash deletion
Browse files Browse the repository at this point in the history
Signed-off-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com>
  • Loading branch information
LE SAULNIER Kevin committed Apr 24, 2024
1 parent cec116b commit b6405b0
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions functions/delete_stashed_elements/delete_stashed_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ def deleted_element_described(element):
def delete_stashed_elements(dry_run):
print("/// stashed elements deletion ///")
stashed_elements = requests.get(constant.GET_DIRECTORY_STASHED_ELEMENTS).json()
print(stashed_elements)
print("Here are the elements that will be deleted")
print("\n".join(map(deleted_element_described, stashed_elements)))
if not dry_run :
data = {'ids': list(map(lambda element: element["elementUuid"], stashed_elements))}
result = requests.delete(constant.DELETE_EXPLORE_ELEMENTS, params=data, headers={"userId": "supervision"})
if result.ok :
print("Elements were deleted with success")
else :
print("An error occurred with status code:", result.status_code)
if not stashed_elements :
print("No element to delete")
else :
print("Here are the elements that will be deleted")
print("\n".join(map(deleted_element_described, stashed_elements)))
if not dry_run :
data = {'ids': list(map(lambda element: element["elementUuid"], stashed_elements))}
result = requests.delete(constant.DELETE_EXPLORE_ELEMENTS, params=data, headers={"userId": "supervision"})
if result.ok :
print("Elements were deleted with success")
else :
print("An error occurred with status code:", result.status_code)

0 comments on commit b6405b0

Please sign in to comment.