Class: WorkOS::AuditLogs
- Inherits:
-
Object
- Object
- WorkOS::AuditLogs
- Defined in:
- lib/workos/audit_logs.rb
Instance Method Summary collapse
-
#create_event(organization_id:, event:, request_options: {}) ⇒ WorkOS::AuditLogEventCreateResponse
Create Event.
-
#create_export(organization_id:, range_start:, range_end:, actions: nil, actors: nil, actor_names: nil, actor_ids: nil, targets: nil, request_options: {}) ⇒ WorkOS::AuditLogExportJson
Create Export.
-
#create_schema(action_name:, targets:, actor: nil, metadata: nil, request_options: {}) ⇒ WorkOS::AuditLogSchemaJson
Create Schema.
-
#get_export(audit_log_export_id:, request_options: {}) ⇒ WorkOS::AuditLogExportJson
Get Export.
-
#get_organization_audit_logs_retention(id:, request_options: {}) ⇒ WorkOS::AuditLogsRetentionJson
Get Retention.
-
#initialize(client) ⇒ AuditLogs
constructor
A new instance of AuditLogs.
-
#list_action_schemas(action_name:, before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AuditLogSchemaJson>
List Schemas.
-
#list_actions(before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AuditLogActionJson>
List Actions.
-
#update_organization_audit_logs_retention(id:, retention_period_in_days:, request_options: {}) ⇒ WorkOS::AuditLogsRetentionJson
Set Retention.
Constructor Details
#initialize(client) ⇒ AuditLogs
Returns a new instance of AuditLogs.
9 10 11 |
# File 'lib/workos/audit_logs.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#create_event(organization_id:, event:, request_options: {}) ⇒ WorkOS::AuditLogEventCreateResponse
Create Event
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/workos/audit_logs.rb', line 184 def create_event( organization_id:, event:, request_options: {} ) body = { "organization_id" => organization_id, "event" => event }.compact response = @client.request( method: :post, path: "/audit_logs/events", auth: true, body: body, request_options: ) result = WorkOS::AuditLogEventCreateResponse.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#create_export(organization_id:, range_start:, range_end:, actions: nil, actors: nil, actor_names: nil, actor_ids: nil, targets: nil, request_options: {}) ⇒ WorkOS::AuditLogExportJson
Create Export
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/workos/audit_logs.rb', line 216 def create_export( organization_id:, range_start:, range_end:, actions: nil, actors: nil, actor_names: nil, actor_ids: nil, targets: nil, request_options: {} ) body = { "organization_id" => organization_id, "range_start" => range_start, "range_end" => range_end, "actions" => actions, "actors" => actors, "actor_names" => actor_names, "actor_ids" => actor_ids, "targets" => targets }.compact response = @client.request( method: :post, path: "/audit_logs/exports", auth: true, body: body, request_options: ) result = WorkOS::AuditLogExportJson.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#create_schema(action_name:, targets:, actor: nil, metadata: nil, request_options: {}) ⇒ WorkOS::AuditLogSchemaJson
Create Schema
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/workos/audit_logs.rb', line 155 def create_schema( action_name:, targets:, actor: nil, metadata: nil, request_options: {} ) body = { "actor" => actor, "targets" => targets, "metadata" => }.compact response = @client.request( method: :post, path: "/audit_logs/actions/#{WorkOS::Util.encode_path(action_name)}/schemas", auth: true, body: body, request_options: ) result = WorkOS::AuditLogSchemaJson.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#get_export(audit_log_export_id:, request_options: {}) ⇒ WorkOS::AuditLogExportJson
Get Export
253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/workos/audit_logs.rb', line 253 def get_export( audit_log_export_id:, request_options: {} ) response = @client.request( method: :get, path: "/audit_logs/exports/#{WorkOS::Util.encode_path(audit_log_export_id)}", auth: true, request_options: ) result = WorkOS::AuditLogExportJson.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#get_organization_audit_logs_retention(id:, request_options: {}) ⇒ WorkOS::AuditLogsRetentionJson
Get Retention
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/workos/audit_logs.rb', line 17 def get_organization_audit_logs_retention( id:, request_options: {} ) response = @client.request( method: :get, path: "/organizations/#{WorkOS::Util.encode_path(id)}/audit_logs_retention", auth: true, request_options: ) result = WorkOS::AuditLogsRetentionJson.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#list_action_schemas(action_name:, before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AuditLogSchemaJson>
List Schemas
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/workos/audit_logs.rb', line 109 def list_action_schemas( action_name:, before: nil, after: nil, limit: nil, order: "desc", request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order }.compact response = @client.request( method: :get, path: "/audit_logs/actions/#{WorkOS::Util.encode_path(action_name)}/schemas", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_action_schemas( action_name: action_name, before: before, after: cursor, limit: limit, order: order, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::AuditLogSchemaJson, filters: {action_name: action_name, before: before, limit: limit, order: order}, fetch_next: fetch_next ) end |
#list_actions(before: nil, after: nil, limit: nil, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AuditLogActionJson>
List Actions
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/workos/audit_logs.rb', line 64 def list_actions( before: nil, after: nil, limit: nil, order: "desc", request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order }.compact response = @client.request( method: :get, path: "/audit_logs/actions", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_actions( before: before, after: cursor, limit: limit, order: order, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::AuditLogActionJson, filters: {before: before, limit: limit, order: order}, fetch_next: fetch_next ) end |
#update_organization_audit_logs_retention(id:, retention_period_in_days:, request_options: {}) ⇒ WorkOS::AuditLogsRetentionJson
Set Retention
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/workos/audit_logs.rb', line 37 def update_organization_audit_logs_retention( id:, retention_period_in_days:, request_options: {} ) body = { "retention_period_in_days" => retention_period_in_days }.compact response = @client.request( method: :put, path: "/organizations/#{WorkOS::Util.encode_path(id)}/audit_logs_retention", auth: true, body: body, request_options: ) result = WorkOS::AuditLogsRetentionJson.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |