forked from uga-libraries/aspace_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish_do_fvs.py
23 lines (18 loc) · 942 Bytes
/
publish_do_fvs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# This script publishes all digital object file versions
from asnake.client import ASnakeClient
from secrets import *
as_username = input("Enter your ArchivesSpace username: ") # input("Enter your ArchivesSpace username: ")
as_password = input("Enter your ArchivesSpace password: ") # input("Enter your ArchivesSpace password: ")
client = ASnakeClient(baseurl=as_api, username=as_username, password=as_password)
client.authorize()
def publish_do_fvs():
repos = client.get("repositories").json()
for repo in repos:
print(repo["name"])
repo_id = repo["uri"].split("/")[2]
response_dos = client.get('repositories/{}/digital_objects'.format(repo_id), params={"all_ids": True})
all_dos = list(response_dos.json())
for do_id in all_dos:
update_do = client.post('repositories/{}/digital_objects/{}/publish'.format(repo_id, do_id))
print(update_do.text)
publish_do_fvs()