DSpace.API.Resource behaviour (dspace_ex v0.1.0-alpha2)

Copy Markdown View Source

Specifies the behaviour of an API resource.

Summary

Types

Represents a "DSpace Object" UUID.

Represents a single metadata update to a resource.

Callbacks

Builds an operation to create a new resource on DSpace.

Builds an operation to delete a resource on DSpace.

Builds an operation to fetch a single resource by UUID.

Builds an operation to fetch resources via DSpace search ("discovery").

Builds an operation to fetch a list of resources.

Builds an operation to replace a resource on DSpace.

Builds an operation to update an existing resource on DSpace.

Types

dso_uuid()

@type dso_uuid() :: binary()

Represents a "DSpace Object" UUID.

Any repository entity (community, collection, item, user, user group, file, etc.) will have a UUID.

options()

@type options() :: keyword()

resource_update()

@type resource_update() :: %{
  required(binary()) => binary(),
  required(binary()) => binary(),
  optional(binary()) => binary() | nil,
  optional(binary()) => binary() | nil
}

Represents a single metadata update to a resource.

Corresponds to a JSON Patch operation as per RFC6902 ("copy" and "test" operations are not implemented by DSpace). Be aware that DSpace defines custom semantics on top of JSON Patch.

Fields

  • op - The operation to perform:
    • add - Sets the value at the target path. Replaces the value if it already exists.
    • remove - Removes the value at the target path. value is not required.
    • replace - Replaces an existing value at the target path. Fails if no value exists.
    • move - Moves the value from from to path. value is not required.
  • path - JSON Pointer to the target location (e.g. "/metadata/dc.title/0/value")
  • value - The value to place at the target path. Required for :add and :replace.
  • from - Source JSON Pointer, only used with :move.

Examples

%{"op" => "replace", "path" => "/metadata/dc.title/0/value", "value" => "New Title"}

Callbacks

create(map, options)

(optional)
@callback create(map(), options()) :: DSpace.API.Operation.t()

Builds an operation to create a new resource on DSpace.

delete(binary, options)

(optional)
@callback delete(binary(), options()) :: DSpace.API.Operation.t()

Builds an operation to delete a resource on DSpace.

fetch(dso_uuid, options)

@callback fetch(dso_uuid(), options()) :: DSpace.API.Operation.t()

Builds an operation to fetch a single resource by UUID.

find(options)

(optional)
@callback find(options()) :: DSpace.API.Operation.t()

Builds an operation to fetch resources via DSpace search ("discovery").

list(options)

@callback list(options()) :: DSpace.API.Operation.t()

Builds an operation to fetch a list of resources.

replace(dso_uuid, map, options)

(optional)
@callback replace(dso_uuid(), map(), options()) :: DSpace.API.Operation.t()

Builds an operation to replace a resource on DSpace.

update(dso_uuid, list, options)

(optional)
@callback update(dso_uuid(), [resource_update()], options()) :: DSpace.API.Operation.t()

Builds an operation to update an existing resource on DSpace.

The payload is a list of t:DSpace.API.Resource.resource_update.t/0.