DSpace.API.Version (dspace_ex v0.2.0)

Copy Markdown View Source

Represents an API compatibility target.

This module resolves compatibility information from a DSpace.API structure and provides helpers for discovering API version information from a live DSpace or DSpace-CRIS instance. Most users will not need to use this module directly. The functionality is mainly used internally (it drives compatibility resolution when executing API operations).

CRIS fork compatibility

The published API spec for the CRIS fork does not list any branches or tags prior to the 2023.01.01 release. Unless where known otherwise, this release is therefore the assumed baseline for operation compatibility checks.

That means all versions prior to this release might be flagged as incompatible to execute an operation, even though they may actually be compatible with the API. If your application targets an older CRIS release and you suspect a false positive:

  • test the operation in question without enabling compatibility checks by not setting cris_version of the DSpace.API.t/0 when you perform it
  • selectively disable the compatibility check for an operation by modifying its before_step so that api_version and cris_version is set to nil in the passed DSpace.API.t/0 or
  • do not enable compatibility checks at all

If you confirmed a false positive, please open an Issue

Summary

Types

Target distribution.

t()

Compatibility target for a DSpace.API client.

Functions

Fetches version information from the API.

Parses a CRIS release string into a Elixir.Version.t/0.

Parses a DSpace version string into a Elixir.Version.t/0.

Resolves compatibility information from a DSpace.API structure.

Types

distribution()

(since 0.2.0)
@type distribution() :: :dspace | :cris | :unknown

Target distribution.

t()

(since 0.2.0)
@type t() :: %DSpace.API.Version{
  api_version: Version.t() | nil,
  cris_version: Version.t() | nil,
  distribution: distribution()
}

Compatibility target for a DSpace.API client.

api_version always refers to the base DSpace version, even when the client is configured to target the CRIS fork

Functions

fetch()

(since 0.2.0)
@spec fetch() :: DSpace.API.Operation.t()

Fetches version information from the API.

Executing this operation returns a t/0 structure.

Example

client =
  [endpoint: "https://example.com/server"]
  |> DSpace.API.new()

{:ok, %DSpace.API.Version{} = version} =
  DSpace.API.Version.fetch()
  |> DSpace.API.request(client)

parse_cris_version(version)

(since 0.2.0)
@spec parse_cris_version(cris_release_string :: binary()) :: Version.t() | nil

Parses a CRIS release string into a Elixir.Version.t/0.

parse_dspace_version(version)

(since 0.2.0)
@spec parse_dspace_version(dspace_version_string :: binary()) :: Version.t() | nil

Parses a DSpace version string into a Elixir.Version.t/0.

resolve(api)

(since 0.2.0)
@spec resolve(DSpace.API.t()) :: t()

Resolves compatibility information from a DSpace.API structure.

The configured values are normalized. When both :api_version and :cris_version are configured, :cris_version determines the distribution. If the base DSpace version is missing or cannot be parsed, an internal CRIS release mapping is used as a fallback.