DSpace.API.Model.ResourceUpdate (dspace_ex v0.2.0)

Copy Markdown View Source

Represents a single update to a resource.

Roughly corresponds to a JSON Patch operation as per RFC6902. Be aware that DSpace defines custom semantics on top of JSON Patch, and "copy" and "test" operations are not implemented.

Examples

%DSpace.API.Resource{
  op: :replace,
  path: "/metadata/dc.title/0/value",
  value: "New Title"
}

Summary

Types

t()

A single update to a resource.

Functions

Creates an update structure to add a value.

Creates a new update structure from a wire format map.

Creates an update structure to move a value.

Creates a new update structure.

Creates an update structure to remove a value.

Creates an update structure to replace a value.

Converts an update structure to a wire format map.

Types

op()

(since 0.2.0)
@type op() :: :add | :remove | :replace | :move

t()

(since 0.2.0)
@type t() :: %DSpace.API.Model.ResourceUpdate{
  from: binary() | nil,
  op: op(),
  path: binary(),
  value: term() | nil
}

A single update to a resource.

  • op - The update 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.

Functions

add(path, value)

(since 0.2.0)
@spec add(binary(), term()) :: t()

Creates an update structure to add a value.

from_map(map)

(since 0.2.0)
@spec from_map(map()) :: t()

Creates a new update structure from a wire format map.

move(from, path)

(since 0.2.0)
@spec move(binary(), binary()) :: t()

Creates an update structure to move a value.

new(attributes)

(since 0.2.0)
@spec new(map() | keyword()) :: t()

Creates a new update structure.

remove(path)

(since 0.2.0)
@spec remove(binary()) :: t()

Creates an update structure to remove a value.

replace(path, value)

(since 0.2.0)
@spec replace(binary(), term()) :: t()

Creates an update structure to replace a value.

to_map(struct)

(since 0.2.0)
@spec to_map(struct()) :: %{required(binary()) => term()}
@spec to_map(t() | map()) :: map()

Converts an update structure to a wire format map.