Skip to content

Instantly share code, notes, and snippets.

@djpillen
Last active February 9, 2017 20:29
Show Gist options
  • Save djpillen/ec6686dc47bd1c3c7d65d8d024a6f4d4 to your computer and use it in GitHub Desktop.
Save djpillen/ec6686dc47bd1c3c7d65d8d024a6f4d4 to your computer and use it in GitHub Desktop.
API endpoint to get the Archival Object IDs associated with an ArchivesSpace Resource
# Add this to a plugin's backend/controllers directory
class ArchivesSpaceService < Sinatra::Base
Endpoint.get('/repositories/:repo_id/resources/:id/archival_object_ids')
.description("Get a list of archival objects IDs associated with a resource")
.params(["id", :id],
["repo_id", :repo_id])
.permissions([:view_repository])
.returns([200, "OK"]) \
do
resource = Resource.get_or_die(params[:id])
graph = resource.object_graph.ids_for(ArchivalObject)
json_response(graph)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment