[Archivesspace_Users_Group] location woes

Majewski, Steven Dennis (sdm7g) sdm7g at eservices.virginia.edu
Wed Sep 14 18:44:28 EDT 2016


Note that that is a DELETE EVERYTHING method. If that not what you want, you need to replace the all_ids curl with a search or something that gets you the ids of items to be deleted.

Sent from my iPhone

On Sep 14, 2016, at 6:26 PM, Majewski, Steven Dennis (sdm7g) <sdm7g at eservices.virginia.edu<mailto:sdm7g at eservices.virginia.edu>> wrote:

How to delete stuff using the API:

I haven’t had to try to delete locations, but the principle is the same for most resources.
Locations are global, not repository based, so you don’t need the /repositories/$REPO_ID in the URL.

Try  /locations/$ID instead of /repositories/$REPO_ID/$THING/$ID.

This was originally written for deleting resources, but I changed it to delete digital_objects ( which don’t get deleted when their owner resource gets deleted. ) I’ve added some annotations to explain.

If you don’t have ‘jq’ installed, you can leave that out. It’s just used to pretty-print the JSON output.

— Steve Majewski

# [1] set variables:

REPO=http://localhost:4567
#
REPO_ID=$1
THING=digital_objects
#
user=
pass=


# [2] clip out the login logic from scripts/curl_as or scripts/curl_as_osx
# If you’re going to repeat this call thousands of times, it’s better to just do it once at the start
# rather than call those scripts and do it many times...

session=$(curl -s -F password="$pass" "$REPO/users/$user/login" |
    sed 's|.*"session":"\([a-z0-9]*\)".*|\1|g')

echo "Repo: $REPO/repositories/$REPO_ID"
echo "Session $session" 1>&2

# [3] Are you sure ?

curl -H "X-ArchivesSpace-Session: $session" "$REPO/repositories/$REPO_ID" | jq .
echo -n "Delete all $THING from this repo? [Y/N]: "; read ANS
if [ "$ANS" = "Y"  ]
then

# [4] get the list of resources using "?all_ids=true”
# this returns a list of IDs. Strip off the “[“, “]” and “,” and iterate over IDs:
# do a DELETE on each resource ID.

DELETE='-X DELETE'
for ID in $( curl  -H "X-ArchivesSpace-Session: $session" "$REPO/repositories/$REPO_ID/${THING}?all_ids=true" | tail -1 | tr '[],' ' ' )
do
curl -H "X-ArchivesSpace-Session: $session" $DELETE $REPO/repositories/$REPO_ID/$THING/$ID | jq .
done

fi




On Sep 14, 2016, at 5:52 PM, library at princeofpeaceabbey.org<mailto:library at princeofpeaceabbey.org> wrote:

Jason,

I too have this problem. I deleted the locations that I did not want from MySql but they still show up. Tried to delete them from AS but It refused. So if you can put the answer in easy to follow directions I would be happy.

Br Raphael
Quoting Jason Loeffler <j at minorscience.com<mailto:j at minorscience.com>>:

Hi Lydia,
You can iterate over the desired location end points via the API and perform a delete operation. Let me know if you need help setting this up.
JL
--
Jason Loeffler
Technology Consultant | The American Academy in Rome
Minor Science | Application Development & Metadata Strategy
Brooklyn, New York
jason at minorscience.com<mailto:jason at minorscience.com>
(347) 405-0826
minorscience (Skype)

_____________________________
From: Tang, Lydia <ltang5 at mail.lib.msu.edu<mailto:ltang5 at mail.lib.msu.edu>>
Sent: Wednesday, September 14, 2016 14:56
Subject: [Archivesspace_Users_Group] location woes
To:  <archivesspace_users_group at lyralists.lyrasis.org<mailto:archivesspace_users_group at lyralists.lyrasis.org>>


Hello everyone,
I’ve definitely learned to try out my more ambitious projects in our test instance after this location snafu.  We tried to roll back the instance to a backup last night, reindexed everything, and the bad locations were all still there!  If any of you know of a way to target mass delete the locations (nearly 6500 location entries), please let me know!
Lydia
_______________________________________________
Archivesspace_Users_Group mailing list
Archivesspace_Users_Group at lyralists.lyrasis.org<mailto:Archivesspace_Users_Group at lyralists.lyrasis.org>
http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group



_______________________________________________
Archivesspace_Users_Group mailing list
Archivesspace_Users_Group at lyralists.lyrasis.org<mailto:Archivesspace_Users_Group at lyralists.lyrasis.org>
http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group

_______________________________________________
Archivesspace_Users_Group mailing list
Archivesspace_Users_Group at lyralists.lyrasis.org<mailto:Archivesspace_Users_Group at lyralists.lyrasis.org>
http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20160914/6224969b/attachment.html>


More information about the Archivesspace_Users_Group mailing list