Module: WorkOS::AuditLogs

Extended by:
Client
Defined in:
lib/workos/audit_logs.rb

Overview

The Audit Logs module provides convenience methods for working with the WorkOS Audit Logs platform. You’ll need a valid API key.

Class Method Summary collapse

Methods included from Client

client, delete_request, execute_request, get_request, handle_error_response, post_request, put_request, user_agent

Class Method Details

.create_event(organization:, event:, idempotency_key: nil) ⇒ nil

Create an Audit Log Event.

Parameters:

  • organization (String)

    An Organization ID

  • event (Hash)

    An Audit Log Event

  • idempotency_key (String) (defaults to: nil)

    An idempotency key

Returns:

  • (nil)
[View source]

20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/workos/audit_logs.rb', line 20

def create_event(organization:, event:, idempotency_key: nil)
  request = post_request(
    path: '/audit_logs/events',
    auth: true,
    idempotency_key: idempotency_key,
    body: {
      organization_id: organization,
      event: event,
    },
  )

  execute_request(request: request)
end

.create_export(organization:, range_start:, range_end:, actions: nil, actors: nil, targets: nil, actor_names: nil, actor_ids: nil) ⇒ WorkOS::AuditLogExport

Create an Export of Audit Log Events.

Parameters:

  • organization (String)

    An Organization ID

  • range_start (String)

    ISO-8601 datetime

  • range_end (String)

    ISO-8601 datetime

  • actions (Array<String>) (defaults to: nil)

    A list of actions to filter by

  • @deprecated (Array<String>)

    use ‘actor_names` instead

  • actor_names (Array<String>) (defaults to: nil)

    A list of actor names to filter by

  • actor_ids (Array<String>) (defaults to: nil)

    A list of actor ids to filter by

  • targets (Array<String>) (defaults to: nil)

    A list of target types to filter by

Returns:

[View source]

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/workos/audit_logs.rb', line 46

def create_export(organization:, range_start:, range_end:, actions: nil, # rubocop:disable Metrics/ParameterLists
                  actors: nil, targets: nil, actor_names: nil, actor_ids: nil)
  body = {
    organization_id: organization,
    range_start: range_start,
    range_end: range_end,
  }

  body['actions'] = actions unless actions.nil?
  body['actors'] = actors unless actors.nil?
  body['actor_names'] = actor_names unless actor_names.nil?
  body['actor_ids'] = actor_ids unless actor_ids.nil?
  body['targets'] = targets unless targets.nil?

  request = post_request(
    path: '/audit_logs/exports',
    auth: true,
    body: body,
  )

  response = execute_request(request: request)

  WorkOS::AuditLogExport.new(response.body)
end

.get_export(id:) ⇒ WorkOS::AuditLogExport

Retrieves an Export of Audit Log Events

Parameters:

  • id (String)

    An Audit Log Export ID

Returns:

[View source]

76
77
78
79
80
81
82
83
84
85
# File 'lib/workos/audit_logs.rb', line 76

def get_export(id:)
  request = get_request(
    auth: true,
    path: "/audit_logs/exports/#{id}",
  )

  response = execute_request(request: request)

  WorkOS::AuditLogExport.new(response.body)
end