In [1]:
Copied!
import requests
# This is the endpoint for the GraphQL API. On a production installation it might be http://<yourservername>/api .
API_URL = "http://localhost:4000/graphql"
# Put your auth token from login here
AUTH_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsImlhdCI6MTY1NTkyMjI5NCwiZXhwIjoxNjU2NTI3MDk0fQ.6aEzi28x5s2jt7bvK2lURJD6Q-afKrf4DpYxofgJHjM"
import requests
# This is the endpoint for the GraphQL API. On a production installation it might be http:///api .
API_URL = "http://localhost:4000/graphql"
# Put your auth token from login here
AUTH_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsImlhdCI6MTY1NTkyMjI5NCwiZXhwIjoxNjU2NTI3MDk0fQ.6aEzi28x5s2jt7bvK2lURJD6Q-afKrf4DpYxofgJHjM"
Changing an event identifier¶
To change the unique identifier for an event to another, use the changeEventsInTrack mutation.
In [2]:
Copied!
def change_events_in_track(source_track_uuid: str, target_track_uuid: str):
query = """ mutation
changeEvents($source_track_uuid: String!, $target_track_uuid: String!) {
changeEventsInTrack(source_track_uuid: $source_track_uuid, target_track_uuid: $target_track_uuid ) {
success
message
}
}
"""
variables = {"source_track_uuid": source_track_uuid, "target_track_uuid": target_track_uuid}
reply = (requests.post(API_URL, headers={'Authorization': f'Bearer {AUTH_TOKEN}'},
json={'query': query, 'variables': variables}).json())
print(reply)
def change_events_in_track(source_track_uuid: str, target_track_uuid: str):
query = """ mutation
changeEvents($source_track_uuid: String!, $target_track_uuid: String!) {
changeEventsInTrack(source_track_uuid: $source_track_uuid, target_track_uuid: $target_track_uuid ) {
success
message
}
}
"""
variables = {"source_track_uuid": source_track_uuid, "target_track_uuid": target_track_uuid}
reply = (requests.post(API_URL, headers={'Authorization': f'Bearer {AUTH_TOKEN}'},
json={'query': query, 'variables': variables}).json())
print(reply)
In [3]:
Copied!
change_events_in_track("835a6453-9cdc-4ad1-8a9b-4c5ef40e1b4f", "09b03505-a50c-46c6-9c0c-202d143c4953")
change_events_in_track("835a6453-9cdc-4ad1-8a9b-4c5ef40e1b4f", "09b03505-a50c-46c6-9c0c-202d143c4953")
{'data': {'changeEventsInTrack': {'success': True, 'message': 'Change all events in the track 835a6453-9cdc-4ad1-8a9b-4c5ef40e1b4f to 09b03505-a50c-46c6-9c0c-202d143c4953'}}}
Copyright (c) 2022, MBARI