OCSF.Status (OCSF v0.1.0)

Copy Markdown View Source

OCSF event status.

Maps event outcome status names to their OCSF 1.8 numeric identifiers. Used by event builders to resolve the :status keyword into the status_id field.

See the OCSF status_id definition.

Values

NameID
:Unknown0
:Success1
:Failure2
:Other99

See OCSF.StatusDetail for well-known status_detail string constants and OCSF.Severity for severity levels.

Summary

Functions

Return values formatted for Ecto.Enum.

Return the name atom for the given numeric identifier.

Return the numeric identifier for the given name atom.

Return true if the given name or identifier is valid.

Return all values as a keyword list.

Functions

ecto_values()

@spec ecto_values() :: keyword()

Return values formatted for Ecto.Enum.

Examples

iex> OCSF.Status.ecto_values()
[Unknown: 0, Success: 1, Failure: 2, Other: 99]

name(uid)

@spec name(integer()) :: atom() | nil

Return the name atom for the given numeric identifier.

Examples

iex> OCSF.Status.name(1)
:Success

iex> OCSF.Status.name(42)
nil

uid(name)

@spec uid(atom()) :: integer() | nil

Return the numeric identifier for the given name atom.

Examples

iex> OCSF.Status.uid(:Success)
1

iex> OCSF.Status.uid(:NonExistent)
nil

valid?(name)

@spec valid?(atom() | integer()) :: boolean()

Return true if the given name or identifier is valid.

Examples

iex> OCSF.Status.valid?(:Success)
true

iex> OCSF.Status.valid?(1)
true

iex> OCSF.Status.valid?(:NonExistent)
false

values()

@spec values() :: [{atom(), integer()}]

Return all values as a keyword list.

Examples

iex> OCSF.Status.values()
[Unknown: 0, Success: 1, Failure: 2, Other: 99]