ExScim.Resources.Metadata (ex_scim v0.2.2)

Copy Markdown View Source

Handles SCIM metadata for resources: timestamping domain structs and computing/formatting the SCIM meta object (including ETag/version).

Summary

Functions

Assembles the SCIM meta JSON object from pre-extracted values.

Computes a weak ETag version string given a raw version value and last-modified timestamp.

Formats a DateTime to ISO 8601 string, passes binaries through, returns nil for nil.

Parses an ISO 8601 string into a DateTime, passes DateTime through, returns nil for nil.

Updates metadata timestamps on a resource.

Functions

build_meta(created, last_modified, version, location, resource_type)

Assembles the SCIM meta JSON object from pre-extracted values.

created and last_modified may be DateTime structs or ISO 8601 strings. version, location, and resource_type may be nil (keys are omitted when nil).

compute_version(version_value, last_modified \\ nil)

Computes a weak ETag version string given a raw version value and last-modified timestamp.

If version_value is non-nil, it is stringified and hashed. Otherwise last_modified is used as the input. Returns nil if both are nil/unavailable.

format_datetime(dt)

Formats a DateTime to ISO 8601 string, passes binaries through, returns nil for nil.

parse_datetime(dt)

Parses an ISO 8601 string into a DateTime, passes DateTime through, returns nil for nil.

update_metadata(resource, resource_type \\ nil)

Updates metadata timestamps on a resource.

Sets meta_last_modified to current time, and meta_created if it's nil. Optionally sets meta_resource_type if provided.