admin_api

package
v0.0.0-...-6b066e2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChecksumCreate

func ChecksumCreate(c *gin.Context)

ChecksumCreate creates a new Checksum. We only do this when ingesting a newer a version of a previously ingested file. On first ingest, we call GenericFileCreateBatch, and the initial checksum is saved there, as part of a batch transaction.

POST /admin-api/v3/checsums/create/:institution_id

func ChecksumFromJson

func ChecksumFromJson(req *api.Request) (*pgmodels.Checksum, error)

ChecksumFromJson returns the Checksum from the JSON in the request body and the existing file record from the database (if there is one). It returns an error if the JSON can't be parsed, if the existing file can't be found, or if changes made to the existing object are not allowed.

func CoerceFileStorageOption

func CoerceFileStorageOption(existingFile, submittedFile *pgmodels.GenericFile)

CoerceFileStorageOption forces submittedFile.StorageOption to match existingFile.StorageOption if existingFile.State is Active. The reason for this is documented in the special note under allowed storage option values at https://aptrust.github.io/userguide/bagging/#allowed-storage-option-values

func CoerceObjectStorageOption

func CoerceObjectStorageOption(existingObject, submittedObject *pgmodels.IntellectualObject)

CoerceObjectStorageOption forces submittedObject.StorageOption to match existingObject.StorageOption if existingObject.State is Active. The reason for this is documented in the special note under allowed storage option values at https://aptrust.github.io/userguide/bagging/#allowed-storage-option-values

func CreateChecksum

func CreateChecksum(c *gin.Context) (*pgmodels.Checksum, error)

func CreateOrUpdateFile

func CreateOrUpdateFile(c *gin.Context) (*pgmodels.GenericFile, error)

func CreateOrUpdateItem

func CreateOrUpdateItem(c *gin.Context) (*pgmodels.WorkItem, error)

func CreateOrUpdateObject

func CreateOrUpdateObject(c *gin.Context) (*pgmodels.IntellectualObject, error)

func CreateStorageRecord

func CreateStorageRecord(c *gin.Context) (*pgmodels.StorageRecord, error)

func DeletionRequestShow

func DeletionRequestShow(c *gin.Context)

DeletionRequestShow shows the deletion request with the specified id.

GET /admin-api/v3/deletions/show/:id

func GenericFileCreate

func GenericFileCreate(c *gin.Context)

GenericFileCreate creates a new GenericFile.

TODO: Change institution_id to object_id? POST /admin-api/v3/files/create/:institution_id

func GenericFileCreateBatch

func GenericFileCreateBatch(c *gin.Context)

GenericFileCreateBatch creates a batch of now GenericFiles and also saves their related records (PremisEvents, Checksums, and StorageRecords). Items in the batch must be new. This won't updated existing records.

TODO: Change institution_id to object_id? POST /admin-api/v3/files/create_batch/:institution_id

func GenericFileDelete

func GenericFileDelete(c *gin.Context)

GenericFileDelete marks a generic file record as deleted. It also creates a deletion premis event. Before it does any of that, it checks a number of pre-conditions. See the GenericFile model for more info.

DELETE /admin-api/v3/files/delete/:id

func GenericFileFromJson

func GenericFileFromJson(req *api.Request) (*pgmodels.GenericFile, error)

GenericFileFromJson returns the GenericFile from the JSON in the request body and the existing file record from the database (if there is one). It returns an error if the JSON can't be parsed, if the existing file can't be found, or if changes made to the existing object are not allowed.

func GenericFileIndex

func GenericFileIndex(c *gin.Context)

GenericFileIndex shows list of files. Unlike the member API, which returns a list of GenericFileView objects, this returns a list of GenericFile objects, complete with checksums, events and storage records. Some of our API workers depend on the related records.

GET /admin-api/v3/files

func GenericFileUpdate

func GenericFileUpdate(c *gin.Context)

GenericFileUpdate updates an existing GenericFile.

PUT /admin-api/v3/files/update/:id

func InstitutionIndex

func InstitutionIndex(c *gin.Context)

InstitutionIndex shows list of institutions.

GET /admin-api/v3/institutions

func InstitutionShow

func InstitutionShow(c *gin.Context)

InstitutionShow returns the institution with the specified id.

GET /admin-api/v3/objects/show/:id

func IntellectualObjectCreate

func IntellectualObjectCreate(c *gin.Context)

IntellectualObjectCreate creates a new object record.

POST /admin-api/v3/objects/create/:institution_id

func IntellectualObjectDelete

func IntellectualObjectDelete(c *gin.Context)

IntellectualObjectDelete marks an object record as deleted. It also creates a deletion premis event. Before it does any of that, it checks a number of pre-conditions. See the IntellectualObject model for more info.

DELETE /admin-api/v3/objects/delete/:id

func IntellectualObjectFromJson

func IntellectualObjectFromJson(req *api.Request) (*pgmodels.IntellectualObject, error)

IntellectualObjectFromJson returns the IntellectualObject from the JSON in the request body and the existing object record from the database (if there is one). It returns an error if the JSON can't be parsed, if the existing object can't be found, or if changes made to the existing object are not allowed.

func IntellectualObjectInitBatchDelete

func IntellectualObjectInitBatchDelete(c *gin.Context)

IntellectualObjectInitBatchDelete creates an deletion request for multiple objects. This request must be approved by an administrator at the depositing institution before the deletion will actually be queued.

Note that becaue this is part of the admin API, access to this call is restricted to APTrust admins.

POST /objects/init_batch_delete

func IntellectualObjectInitRestore

func IntellectualObjectInitRestore(c *gin.Context)

IntellectualObjectInitRestore creates an object restoration request, which is really just a WorkItem that gets queued. Restoration can take seconds or hours, depending on where the object is stored and how big it is. POST /admin-api/v3/objects/init_restore/:id

func IntellectualObjectUpdate

func IntellectualObjectUpdate(c *gin.Context)

IntellectualObjectUpdate updates an existing intellectual object record.

PUT /admin-api/v3/objects/update/:id

func PremisEventCreate

func PremisEventCreate(c *gin.Context)

PremisEventCreate creates a new Premis Event. This function is open to sys admin only. Note that Premis Events cannot be updated or deleted. Also note that this expects a JSON body, not form values.

POST /admin-api/v3/events/create

func PrepareFileDelete

func PrepareFileDelete(c *gin.Context)

PrepareFileDelete is not implemented, except in test and integration builds.

POST /admin-api/v3/prepare_file_delete/:id

func PrepareObjectDelete

func PrepareObjectDelete(c *gin.Context)

PrepareObjectDelete is not implemented, except in test and integration builds.

POST /admin-api/v3/prepare_object_delete/:id

func StorageRecordCreate

func StorageRecordCreate(c *gin.Context)

StorageRecordCreate creates a new StorageRecord. We only do this when ingesting a newer a version of a previously ingested file. On first ingest, we call GenericFileCreateBatch, and the initial checksum is saved there, as part of a batch transaction.

POST /admin-api/v3/storage_records/create/:institution_id

func StorageRecordFromJson

func StorageRecordFromJson(req *api.Request) (*pgmodels.StorageRecord, error)

StorageRecordFromJson returns the StorageRecord from the JSON in the request body and the existing file record from the database (if there is one). It returns an error if the JSON can't be parsed, if the existing file can't be found, or if changes made to the existing object are not allowed.

func StorageRecordIndex

func StorageRecordIndex(c *gin.Context)

StorageRecordIndex shows list of objects.

GET /admin-api/v3/storage_records

func StorageRecordShow

func StorageRecordShow(c *gin.Context)

StorageRecordShow returns the object with the specified id.

GET /admin-api/v3/storage_records/show/:id

func StringSliceToInt64Slice

func StringSliceToInt64Slice(strSlice []string) ([]int64, error)

func WorkItemCreate

func WorkItemCreate(c *gin.Context)

WorkItemCreate creates a new WorkItem.

POST /admin-api/v3/items/create/:institution_id

func WorkItemFromJson

func WorkItemFromJson(req *api.Request) (*pgmodels.WorkItem, error)

WorkItemFromJson returns the WorkItem from the JSON in the request body and the existing file record from the database (if there is one). It returns an error if the JSON can't be parsed, if the existing file can't be found, or if changes made to the existing object are not allowed.

func WorkItemRedisDelete

func WorkItemRedisDelete(c *gin.Context)

WorkItemRedisDelete deletes a WorkItem's Redis record. This is an admin-only feature.

DELETE /admin-api/v3/items/redis_delete/:id

func WorkItemRequeue

func WorkItemRequeue(c *gin.Context)

WorkItemRequeue requeues a WorkItem to the specified stage.

PUT /admin-api/v3/items/requeue/:id

func WorkItemUpdate

func WorkItemUpdate(c *gin.Context)

WorkItemUpdate updates an existing WorkItem record.

PUT /admin-api/v3/items/update/:id

Types

type ObjectBatchDeleteParams

type ObjectBatchDeleteParams struct {
	InstitutionID int64   `json:"institutionId"`
	RequestorID   int64   `json:"requestorId"`
	ObjectIDs     []int64 `json:"objectIds"`
	SecretKey     string  `json:"secretKey"`
}

ObjectBatchDeleteParams contains info about which objects to delete in an object batch delete operation.

We use this struct for two reasons:

1. JSON is easier to craft than a form with a thousand values.

  1. Because the httptest library is lame and cannot properly create multiple form values with the same name due to a problem with the underlying github.com/ajg/form library. It turns all params into a flat map. This is documented. So instead of getting objectIds = [1,2,3,4] as url.Values would give it to us, we get objectIds.0 = 1, objectIds.1 = 2, objectIds.3 = 2, etc. That's worthless in a testing library that needs to be able to pass values in the standard format that the back end expects.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL