FusionAuth.AuditLogs (FusionAuth v0.3.0) View Source

The FusionAuth.AuditLogs module provides access functions to the FusionAuth Audit Logs API.

All functions require a Tesla Client struct created with FusionAuth.client(base_url, api_key, tenant_id).

Audit Log Fields

  • data :: map()

Additional details of an audit log.

  • newValue :: String.t()

The new value of the changed object.

  • oldValue :: String.t()

The previous value of the changed object.

  • reason :: String.t()

The reason why the audit log was created.

  • id :: integer()

The Audit Log unique id.

  • insertInstant :: integer()

The instant when the Audit Log was created.

  • insertUser :: String.t()

The user that created the Audit Log.

  • message :: String.t()

The message of the Audit Log.

Link to this section Summary

Functions

Export the audit logs. The response will be a compressed archive byte stream with a Content-Type of application/zip.

Get an audit log by ID.

Search and paginate through audit logs.

Link to this section Types

Specs

audit_log() :: %{
  data: map() | nil,
  newValue: String.t() | nil,
  oldValue: String.t() | nil,
  reason: String.t() | nil,
  insertUser: String.t(),
  message: String.t()
}

Specs

client() :: FusionAuth.client()

Specs

export_criteria() :: %{
  end: integer() | nil,
  message: String.t() | nil,
  start: integer() | nil,
  user: String.t() | nil,
  dateTimeSecondsFormat: String.t() | nil,
  zoneId: String.t()
}

Specs

result() :: FusionAuth.result()

Specs

search_criteria() ::
  %{
    end: integer() | nil,
    message: String.t() | nil,
    numberOfResults: integer() | nil,
    orderBy: String.t() | nil,
    start: integer() | nil,
    startRow: integer() | nil,
    user: String.t() | nil
  }
  | map()

Link to this section Functions

Link to this function

create_audit_log(client, audit_log)

View Source

Specs

create_audit_log(client(), audit_log()) :: result()

Create an audit log.

Examples

iex> client = FusionAuth.client(...)
iex> FusionAuth.AuditLogs.create_audit_log(client, %{insertUser: "john.doe@email.com", message: "This is a new audit log."})
{
  :ok,
  %{
    "auditLog" => %{
      "id" => 212,
      "insertInstant" => 1594942979998,
      "insertUser" => "john.doe@email.com",
      "message" => "This is a new audit log."
    }
  },
  %Tesla.Env{...}
}

For more information visit the FusionAuth API Documentation for Add an Entry to the Audit Log.

Link to this function

export_audit_logs(client, criteria)

View Source

Specs

export_audit_logs(client(), export_criteria()) :: result()

Export the audit logs. The response will be a compressed archive byte stream with a Content-Type of application/zip.

Examples

iex> client = FusionAuth.client(...)
iex> FusionAuth.AuditLogs.export(client, %{start: 1594922276379, user: "john.doe@email.com"})
{
  :ok,
  <<80, 75, 3, 4, 20, 0, 8, 8, 8, 0, 77, 188, 240, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 13, 0, 0, 0, 97, 117, 100, 105, 116, 95, 108, 111, 103, 46, 99, 115,
  118, 237, 125, 107, 115, 19, ...>>,
  %Tesla.Env{...}
}

For more information visit the FusionAuth API Documentation for Export Audit Logs.

Link to this function

get_audit_log(client, audit_log_id)

View Source

Specs

get_audit_log(client(), integer()) :: result()

Get an audit log by ID.

Examples

iex> client = FusionAuth.client(...)
iex> FusionAuth.AuditLogs.get_audit_log(client, 211)
{
  :ok,
  %{
    "auditLog" => %{
      "id" => 211,
      "insertInstant" => 1594922276379,
      "insertUser" => "john.doe@email.com",
      "message" => "Deleted user registration for user with Id [12345] and the application with Id [67892]",
      "reason" => "FusionAuth User Interface"
    }
  },
  %Tesla.Env{...}
}

For more information visit the FusionAuth API Documentation for Retrieve an Audit Log.

Link to this function

search_audit_logs(client, search)

View Source

Specs

search_audit_logs(client(), search_criteria()) :: result()

Search and paginate through audit logs.

Examples

iex> client = FusionAuth.client(...)
iex> FusionAuth.AuditLogs.search(client, %{message: "Deleted*", numberOfResults: 2, user: "john.doe@email.com"})
{
  :ok,
  %{
    "auditLogs" => [
      %{
        "id" => 211,
        "insertInstant" => 1594922276379,
        "insertUser" => "john.doe@email.com",
        "message" => "Deleted user registration for user with Id [12345] and the application with Id [67892]",
        "reason" => "FusionAuth User Interface"
      },
      %{
        "id" => 208,
        "insertInstant" => 1594920876552,
        "insertUser" => "john.doe@email.com",
        "message" => "Deleted user with Id [12345]",
        "reason" => "FusionAuth User Interface"
      }
    ],
    "total" => 62
  },
  %Tesla.Env{...}
}

For more information visit the FusionAuth API Documentation for Search the Audit Log.