Difference between revisions of "Storage Service API"
(Initial structure & info) |
(Expand Space & Pipeline endpoint docs) |
||
Line 6: | Line 6: | ||
{| class="wikitable" style="background-color:#ffeecc;" cellpadding="10"; | {| class="wikitable" style="background-color:#ffeecc;" cellpadding="10"; | ||
− | | Improvement Note: TastyPie is less well supported than [http://www.django-rest-framework.org/ Django REST Framework], both in terms of docs & community. We should look at replacing TastyPie with DRF. | + | | Improvement Note: TastyPie is less well supported than [http://www.django-rest-framework.org/ Django REST Framework], both in terms of docs & community. We should look at replacing TastyPie with DRF. |
|} | |} | ||
Endpoints require authentication with a username and API key. This can be submitted as GET parameters (eg <code>?username=test&api_key=e6282adabed84e39ffe451f8bf6ff1a67c1fc9f2</code>) or as a header (eg <code>Authorization: ApiKey test:e6282adabed84e39ffe451f8bf6ff1a67c1fc9f2</code>) | Endpoints require authentication with a username and API key. This can be submitted as GET parameters (eg <code>?username=test&api_key=e6282adabed84e39ffe451f8bf6ff1a67c1fc9f2</code>) or as a header (eg <code>Authorization: ApiKey test:e6282adabed84e39ffe451f8bf6ff1a67c1fc9f2</code>) | ||
− | |||
− | |||
== Pipeline == | == Pipeline == | ||
Line 19: | Line 17: | ||
* '''URL''': <code>/api/v2/pipeline/</code> | * '''URL''': <code>/api/v2/pipeline/</code> | ||
* '''Verb''': GET | * '''Verb''': GET | ||
+ | * '''Parameters''': Query string parameters | ||
+ | ** <code>description</code>: Description of the pipeline | ||
+ | ** <code>uuid</code>: UUID of the pipeline | ||
+ | * '''Response''': JSON | ||
+ | ** <code>meta</code>: Metadata on the response: number of hits, pagination information | ||
+ | ** <code>objects</code>: List of pipelines. See [[#Get pipeline details]] for format | ||
+ | |||
+ | Returns information about all the pipelines in the system. Can be [http://django-tastypie.readthedocs.io/en/latest/resources.html#basic-filtering filtered] by the description or uuid. Disabled pipelines are not returned. | ||
+ | |||
+ | Example: | ||
+ | $ curl -X GET -H"Authorization: ApiKey test:95141fc645ed97a95893f1f865d24687f89a27ad" 'http://localhost:8000/api/v2/pipeline/?description__startswith=Archivematica' | python -m json.tool | ||
+ | { | ||
+ | "meta": { | ||
+ | "limit": 20, | ||
+ | "next": null, | ||
+ | "offset": 0, | ||
+ | "previous": null, | ||
+ | "total_count": 1 | ||
+ | }, | ||
+ | "objects": [ | ||
+ | { | ||
+ | "description": "Archivematica on alouette", | ||
+ | "remote_name": "127.0.0.1", | ||
+ | "resource_uri": "/api/v2/pipeline/dd354557-9e6e-4918-9fe3-a65b00ecb1af/", | ||
+ | "uuid": "dd354557-9e6e-4918-9fe3-a65b00ecb1af" | ||
+ | } | ||
+ | ] | ||
+ | } | ||
=== Create new pipeline === | === Create new pipeline === | ||
Line 25: | Line 51: | ||
* '''Verb''': POST | * '''Verb''': POST | ||
* '''Parameters''': JSON body | * '''Parameters''': JSON body | ||
+ | ** Should contain fields for a new pipeline: <code>uuid</code>, <code>description</code>, <code>api_key</code>, <code>api_username</code> | ||
** <code>create_default_locations</code>: If True, will associated default [[Storage Service#Locations | Locations]] with the newly created pipeline | ** <code>create_default_locations</code>: If True, will associated default [[Storage Service#Locations | Locations]] with the newly created pipeline | ||
** <code>shared_path</code>: If default locations are created, created the [[Storage Service#Currently Processing | processing]] location at this path in the local filesystem | ** <code>shared_path</code>: If default locations are created, created the [[Storage Service#Currently Processing | processing]] location at this path in the local filesystem | ||
+ | ** <code>remote_name</code>: IP or hostname of the pipeline. If not provided and <code>create_default_locations</code> is set, will try to populate from the IP of the request. | ||
+ | * '''Response''': JSON with data for the pipeline | ||
If the 'Pipelines disabled on creation' setting is set, the pipeline will be disabled by default, and will not respond to queries. | If the 'Pipelines disabled on creation' setting is set, the pipeline will be disabled by default, and will not respond to queries. | ||
+ | |||
+ | Example: | ||
+ | $ curl -X POST -H"Authorization: ApiKey test:95141fc645ed97a95893f1f865d24687f89a27ad" -H"Content-Type: application/json" -d'{"uuid": "99354557-9e6e-4918-9fe3-a65b00ecb199", "description": "Test pipeline", "create_default_locations": true, "api_username": "demo", "api_key": "03ecb307f5b8012f4771d245d534830378a87259"}' 'http://192.168.1.42:8000/api/v2/pipeline/' | ||
+ | { | ||
+ | "create_default_locations": true, | ||
+ | "description": "Test pipeline", | ||
+ | "remote_name": "192.168.1.42", | ||
+ | "resource_uri": "/api/v2/pipeline/99354557-9e6e-4918-9fe3-a65b00ecb199/", | ||
+ | "uuid": "99354557-9e6e-4918-9fe3-a65b00ecb199" | ||
+ | } | ||
=== Get pipeline details === | === Get pipeline details === | ||
Line 34: | Line 73: | ||
* '''URL''': <code>/api/v2/pipeline/<UUID>/</code> | * '''URL''': <code>/api/v2/pipeline/<UUID>/</code> | ||
* '''Verb''': GET | * '''Verb''': GET | ||
+ | * '''Parameters''': None | ||
+ | * '''Response''': JSON | ||
+ | ** <code>description</code>: Pipeline description | ||
+ | ** <code>remote_name</code>: IP or hostname of the pipeline. For use in API calls | ||
+ | ** <code>resource_uri</code>: URI for this pipeline in the API | ||
+ | ** <code>uuid</code>: UUID of the pipeline | ||
== Space == | == Space == | ||
Line 45: | Line 90: | ||
* '''URL''': <code>/api/v2/space/</code> | * '''URL''': <code>/api/v2/space/</code> | ||
* '''Verb''': GET | * '''Verb''': GET | ||
+ | * '''Parameters''': Query string parameters | ||
+ | ** <code>access_protocol</code>: Protocol that the [[Storage Service#Space | Space]] uses. Must be searched based on the database code. | ||
+ | ** <code>path</code>: Space's path | ||
+ | ** <code>size</code>: Maximum size in bytes. Can use greater than (size__gt=1024), less than (size__lt=1024), and other Django [https://docs.djangoproject.com/en/1.8/ref/models/querysets/#field-lookups field lookups]. | ||
+ | ** <code>used</code>: Bytes stored in this space. Can use greater than (size__gt=1024), less than (size__lt=1024), and other Django [https://docs.djangoproject.com/en/1.8/ref/models/querysets/#field-lookups field lookups]. | ||
+ | ** <code>uuid</code>: UUID of the Space | ||
+ | * '''Response''': JSON | ||
+ | ** <code>meta</code>: Metadata on the response: number of hits, pagination information | ||
+ | ** <code>objects</code>: List of spaces. See [[#Get space details]] for format | ||
+ | |||
+ | Returns information about all the spaces in the system. Can be [http://django-tastypie.readthedocs.io/en/latest/resources.html#basic-filtering filtered] by several fields: access protocol, path, size, amount used, UUID and verified status. Disabled spaces are not returned. | ||
=== Get space details === | === Get space details === | ||
Line 50: | Line 106: | ||
* '''URL''': <code>/api/v2/space/<UUID>/</code> | * '''URL''': <code>/api/v2/space/<UUID>/</code> | ||
* '''Verb''': GET | * '''Verb''': GET | ||
+ | * '''Parameters''': None | ||
+ | * '''Response''': JSON | ||
+ | ** <code>access_protocol</code>: Database code for the access protocol | ||
+ | ** <code>last_verified</code>: Date of last verification. This is a stub feature | ||
+ | ** <code>path</code>: Space's path | ||
+ | ** <code>resource_uri</code>: URI to the resource in the API | ||
+ | ** <code>size</code>: Maximum size of the space in bytes. | ||
+ | ** <code>used</code>: Bytes stored in this space. | ||
+ | ** <code>uuid</code>: UUID of the space | ||
+ | ** <code>verified</code>: If the space is verified. This is a stub feature | ||
+ | ** Other space-specific fields | ||
=== Browse space path === | === Browse space path === | ||
Line 58: | Line 125: | ||
** <code>path</code>: Path inside the Space to look | ** <code>path</code>: Path inside the Space to look | ||
* '''Response''': JSON | * '''Response''': JSON | ||
− | ** <code>entries</code>: List of entries | + | ** <code>entries</code>: List of entries at path, files or directories |
− | ** <code>directories</code>: List of directories in | + | ** <code>directories</code>: List of directories in path. Subset of `entries`. |
{| class="wikitable" style="background-color:#ffffcc;" cellpadding="10"; | {| class="wikitable" style="background-color:#ffffcc;" cellpadding="10"; |
Revision as of 17:05, 13 March 2017
Main Page > Development > Storage Service API
The Storage Service API provides programmatic access to moving files around in storage areas that the Storage Service has access to.
The API is written using TastyPie.
Improvement Note: TastyPie is less well supported than Django REST Framework, both in terms of docs & community. We should look at replacing TastyPie with DRF. |
Endpoints require authentication with a username and API key. This can be submitted as GET parameters (eg ?username=test&api_key=e6282adabed84e39ffe451f8bf6ff1a67c1fc9f2
) or as a header (eg Authorization: ApiKey test:e6282adabed84e39ffe451f8bf6ff1a67c1fc9f2
)
Pipeline
Get all pipelines
- URL:
/api/v2/pipeline/
- Verb: GET
- Parameters: Query string parameters
description
: Description of the pipelineuuid
: UUID of the pipeline
- Response: JSON
meta
: Metadata on the response: number of hits, pagination informationobjects
: List of pipelines. See #Get pipeline details for format
Returns information about all the pipelines in the system. Can be filtered by the description or uuid. Disabled pipelines are not returned.
Example:
$ curl -X GET -H"Authorization: ApiKey test:95141fc645ed97a95893f1f865d24687f89a27ad" 'http://localhost:8000/api/v2/pipeline/?description__startswith=Archivematica' | python -m json.tool { "meta": { "limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 1 }, "objects": [ { "description": "Archivematica on alouette", "remote_name": "127.0.0.1", "resource_uri": "/api/v2/pipeline/dd354557-9e6e-4918-9fe3-a65b00ecb1af/", "uuid": "dd354557-9e6e-4918-9fe3-a65b00ecb1af" } ] }
Create new pipeline
- URL:
/api/v2/pipeline/
- Verb: POST
- Parameters: JSON body
- Should contain fields for a new pipeline:
uuid
,description
,api_key
,api_username
create_default_locations
: If True, will associated default Locations with the newly created pipelineshared_path
: If default locations are created, created the processing location at this path in the local filesystemremote_name
: IP or hostname of the pipeline. If not provided andcreate_default_locations
is set, will try to populate from the IP of the request.
- Should contain fields for a new pipeline:
- Response: JSON with data for the pipeline
If the 'Pipelines disabled on creation' setting is set, the pipeline will be disabled by default, and will not respond to queries.
Example:
$ curl -X POST -H"Authorization: ApiKey test:95141fc645ed97a95893f1f865d24687f89a27ad" -H"Content-Type: application/json" -d'{"uuid": "99354557-9e6e-4918-9fe3-a65b00ecb199", "description": "Test pipeline", "create_default_locations": true, "api_username": "demo", "api_key": "03ecb307f5b8012f4771d245d534830378a87259"}' 'http://192.168.1.42:8000/api/v2/pipeline/' { "create_default_locations": true, "description": "Test pipeline", "remote_name": "192.168.1.42", "resource_uri": "/api/v2/pipeline/99354557-9e6e-4918-9fe3-a65b00ecb199/", "uuid": "99354557-9e6e-4918-9fe3-a65b00ecb199" }
Get pipeline details
- URL:
/api/v2/pipeline/<UUID>/
- Verb: GET
- Parameters: None
- Response: JSON
description
: Pipeline descriptionremote_name
: IP or hostname of the pipeline. For use in API callsresource_uri
: URI for this pipeline in the APIuuid
: UUID of the pipeline
Space
Improvement Note: Is there no way to create Spaces in the API? |
Get all spaces
- URL:
/api/v2/space/
- Verb: GET
- Parameters: Query string parameters
access_protocol
: Protocol that the Space uses. Must be searched based on the database code.path
: Space's pathsize
: Maximum size in bytes. Can use greater than (size__gt=1024), less than (size__lt=1024), and other Django field lookups.used
: Bytes stored in this space. Can use greater than (size__gt=1024), less than (size__lt=1024), and other Django field lookups.uuid
: UUID of the Space
- Response: JSON
meta
: Metadata on the response: number of hits, pagination informationobjects
: List of spaces. See #Get space details for format
Returns information about all the spaces in the system. Can be filtered by several fields: access protocol, path, size, amount used, UUID and verified status. Disabled spaces are not returned.
Get space details
- URL:
/api/v2/space/<UUID>/
- Verb: GET
- Parameters: None
- Response: JSON
access_protocol
: Database code for the access protocollast_verified
: Date of last verification. This is a stub featurepath
: Space's pathresource_uri
: URI to the resource in the APIsize
: Maximum size of the space in bytes.used
: Bytes stored in this space.uuid
: UUID of the spaceverified
: If the space is verified. This is a stub feature- Other space-specific fields
Browse space path
- URL:
/api/v2/space/<UUID>/browse/
- Verb: GET
- Parameters: Query string parameters
path
: Path inside the Space to look
- Response: JSON
entries
: List of entries at path, files or directoriesdirectories
: List of directories in path. Subset of `entries`.
Version 1: Returns paths as strings
Version 2: Returns all paths base64 encoded |
Location
Improvement Note: Is there no way to create Locations in the API? |
Get all locations
- URL:
/api/v2/location/
- Verb: GET
Get location details
- URL:
/api/v2/location/<UUID>/
- Verb: GET
Move files to this location
- URL:
/api/v2/location/<UUID>/
- Verb: POST
- Parameters: JSON body
origin_location
: URI of the Location the files should be moved frompipeline
: URI of the pipeline. Both Locations must be associated with this pipeline.files
: List of dicts containingsource
anddestination
. The source and destination are paths relative to their Location of the files to be moved.
Intended for use with creating Transfers, SIPs, etc and other cases where files need to be moved but not tracked by the storage service.
Browse location path
- URL:
/api/v2/location/<UUID>/browse/
- Verb: GET
- Parameters: Query string parameters
path
: Path inside the Location to look
- Response: JSON
entries
: List of entries in `path`, files or directoriesdirectories
: List of directories in `path`. Subset of `entries`.
Version 1: Returns paths as strings
Version 2: Returns all paths base64 encoded |
SWORD collection
- URL:
/api/v2/location/<UUID>/sword/collection/
- Verb: GET, POST
See Sword API for details
Package
Get all packages
- URL:
/api/v2/file/
- Verb: GET
Create new package
- URL:
/api/v2/file/
- Verb: POST
Get package details
- URL:
/api/v2/file/<UUID>/
- Verb: GET
? detail PUT
- URL:
/api/v2/file/<UUID>/
- Verb: PUT
? detail PATCH
- URL:
/api/v2/file/<UUID>/
- Verb: PATCH
Used to update the reingest status.
Delete AIP request
- URL:
/api/v2/file/<UUID>/delete_aip/
- Verb: POST
- Parameters: JSON body
event_reason
: Reason for deleting the AIPpipeline
: URI of the pipeline the delete request is fromuser_id
: User ID requesting the deletion. This is the ID of the user on the pipeline, and must be an integer greater than 0.user_email
: Email of the user requesting the deletion.
Recover AIP request
- URL:
/api/v2/file/<UUID>/recover_aip/
- Verb: POST
- Parameters: JSON body
event_reason
: Reason for recovering the AIPpipeline
: URI of the pipeline the recovery request is fromuser_id
: User ID requesting the recovery. This is the ID of the user on the pipeline, and must be an integer greater than 0.user_email
: Email of the user requesting the recovery.
Download single file
- URL:
/api/v2/file/<UUID>/extract_file/
- Verb: GET, HEAD
- Parameters: Query string parameters
relative_path_to_file
: Path to the file to download, relative to the package path.
- Response: Stream of the requested file
Returns a single file from the Package. If the package is compressed, it downloads the whole AIP and extracts it.
This responds to HEAD because AtoM uses HEAD to check for the existence of a file.
Improvement Note: HEAD and GET should not perform the same functions. HEAD should be updated to not return the file, and to only check for existence. Currently, the storage service has no way to check if a file exists except by downloading and extracting this AIP |
If the package is in Arkivum, the package may not actually be available. This endpoint checks if the package is locally available. If it is, it is returned as normal. If not, it returns 202
and emails the administrator about the attempted access.
Download package
- URL:
/api/v2/file/<UUID>/download/
- URL:
/api/v2/file/<UUID>/download/<chunk number>/
(for LOCKSS harvesting) - Verb: GET, HEAD
- Parameters: None
- Response: Stream of the package
Returns the entire package as a single file. If the AIP is uncompressed, create one file by using `tar`.
If the download URL has a chunk number, it will attempt to serve the LOCKSS chunk specified for that package. If the package is not in LOCKSS, it will return the the whole package.
This responds to HEAD because AtoM uses HEAD to check for the existence of a file.
Improvement Note: HEAD and GET should not perform the same functions. HEAD should be updated to not return the file, and to only check for existence. |
If the package is in Arkivum, the package may not actually be available. This endpoint checks if the package is locally available. If it is, it is returned as normal. If not, it returns 202
and emails the administrator about the attempted access.
Get pointer file
- URL:
/api/v2/file/<UUID>/pointer_file/
- Verb: GET
- Parameters: None
- Response: Stream of the pointer file.
Check fixity
- URL:
/api/v2/file/<UUID>/check_fixity/
- Verb: GET
- Parameters: Query string parameters
force_local
: If true, download and run fixity on the AIP locally, instead of using the Space-provided fixity if available.
- Response: JSON
success
: True if the verification succeeded, False if the verification failed, None if the scan could not startmessage
: Human-readable string explaining the report; it will be empty for successful scans.failures
: List of 0 or more errorstimestamp
: ISO-formated string with the datetime of the last fixity check. If the check was performed by an external system, this will be provided by that system. If not provided,or on error, it will be None.
AIP storage callback request
- URL:
/api/v2/file/<UUID>/send_callback/post_store/
- Verb: GET
Request to call any Callbacks configured to run post-storage for this AIP.
Improvement Note: This only works on locally available AIPs (AIPs stored in Spaces that are available via a UNIX filesystem layer). |
Get file information for package
- URL:
/api/v2/file/<UUID>/contents/
- Verb: GET
- Response: JSON
success
: Truepackage
: UUID of the packagefiles
: List of dictionaries with file information. Each dictionary has:source_id
: UUID of the file to indexname
: Relative path of the file inside the packagesource_package
: UUID of the SIP this file is fromchecksum
: Checksum of the file, or an empty stringaccessionid
: Accession number, or an empty stringorigin
: UUID of the Archivematica dashboard this is from
Returns metadata about every file within the package.
Update file information for package
- URL:
/api/v2/file/<UUID>/contents/
- Verb: PUT
- Parameters: JSON list of dictionaries with information on the files to be added. Each dict must have the following attributes:
relative_path
: Relative path of the file inside the packagefileuuid
: UUID of the file to indexaccessionid
: Accession number, or an empty stringsipuuid
: UUID of the SIP this file is fromorigin
: UUID of the Archivematica dashboard this is from
Adds a set of files to a package.
Delete file information for package
- URL:
/api/v2/file/<UUID>/contents/
- Verb: DELETE
Removes all file records associated with this package.
Query file information on packages
- URL:
/api/v2/file/metadata/
- Verb: GET, POST
- Parameters: Query string parameters. Must have at least one, but not all are required
relative_path
: Relative path of the file inside the packagefileuuid
: UUID of the fileaccessionid
: Accession numbersipuuid
: UUID of the SIP this file is from
- Response: JSON. List of dicts with file information about the files that match the query.
accessionid
: Accession number, or an empty stringfile_extension
: File extensionfilename
: Name of the file, sans path.relative_path
: Relative path of the file inside the packagefileuuid
: UUID of the file to indexsipuuid
: UUID of the SIP this file is fromorigin
: UUID of the Archivematica dashboard this is from
Reingest AIP
- URL:
/api/v2/file/<UUID>/reingest/
- Verb: POST
- Parameters: JSON body
pipeline
: UUID of the pipeline to reingest onreingest_type
: Type of reingest to start. One ofMETADATA_ONLY
(metadata-only reingest),OBJECTS
(partial reingest),FULL
(full reingest)processing_config
: Optional. Name of the processing configuration to use on full reingest
SWORD endpoints
- URL:
/api/v2/file/<UUID>/sword/
- URL:
/api/v2/file/<UUID>/sword/media/
- URL:
/api/v2/file/<UUID>/sword/state/
See Sword API for details.