1
0
Fork 0

Sync Mode

Explicitly check for 403 status codes when fetching libraries or triggering offline asset removal to throw the appropriate error
This commit is contained in:
Salvoxia 2024-08-18 12:07:43 +02:00
parent 92493ad85b
commit 861dddfbbe

View file

@ -478,7 +478,10 @@ def fetchLibraries():
apiEndpoint = 'libraries' apiEndpoint = 'libraries'
r = requests.get(root_url+apiEndpoint, **requests_kwargs) r = requests.get(root_url+apiEndpoint, **requests_kwargs)
assert r.status_code in [200, 201] if r.status_code == 403:
logging.fatal("--sync-mode 2 requires an Admin User API key!")
else:
assert r.status_code in [200, 201]
return r.json() return r.json()
def triggerOfflineAssetRemoval(libraryId: str): def triggerOfflineAssetRemoval(libraryId: str):
@ -497,7 +500,10 @@ def triggerOfflineAssetRemoval(libraryId: str):
apiEndpoint = 'libraries/'+libraryId+'/removeOffline' apiEndpoint = 'libraries/'+libraryId+'/removeOffline'
r = requests.post(root_url+apiEndpoint, **requests_kwargs) r = requests.post(root_url+apiEndpoint, **requests_kwargs)
assert r.status_code == 204 if r.status_code == 403:
logging.fatal("--sync-mode 2 requires an Admin User API key!")
else:
assert r.status_code == 204
# append trailing slash to all root paths # append trailing slash to all root paths