Class: WorkOS::AuditLogs
- Inherits:
-
Object
- Object
- WorkOS::AuditLogs
- Defined in:
- lib/workos/audit_logs.rb
Defined Under Namespace
Classes: RetentionPeriod, RetentionPeriodInDays
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::AuditLogExport
Create Export.
-
#create_schema(action_name:, targets:, actor: nil, metadata: nil, request_options: {}) ⇒ WorkOS::AuditLogSchema
Create Schema.
-
#get_export(audit_log_export_id:, request_options: {}) ⇒ WorkOS::AuditLogExport
Get Export.
-
#get_organization_audit_logs_retention(id:, request_options: {}) ⇒ WorkOS::AuditLogsRetention
Get Retention.
-
#initialize(client) ⇒ AuditLogs
constructor
A new instance of AuditLogs.
-
#list_action_schemas(action_name:, before: nil, after: nil, limit: 10, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AuditLogSchema>
List Schemas.
-
#list_actions(before: nil, after: nil, limit: 10, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AuditLogAction>
List Actions.
-
#update_organization_audit_logs_retention(id:, retention:, request_options: {}) ⇒ WorkOS::AuditLogsRetention
Set Retention.
Constructor Details
#initialize(client) ⇒ AuditLogs
Returns a new instance of AuditLogs.
21 22 23 |
# File 'lib/workos/audit_logs.rb', line 21 def initialize(client) @client = client end |
Instance Method Details
#create_event(organization_id:, event:, request_options: {}) ⇒ WorkOS::AuditLogEventCreateResponse
Create Event
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/workos/audit_logs.rb', line 202 def create_event( organization_id:, event:, request_options: {} ) body = { "organization_id" => organization_id, "event" => event } 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::AuditLogExport
Create Export
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/workos/audit_logs.rb', line 234 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::AuditLogExport.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::AuditLogSchema
Create Schema
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/workos/audit_logs.rb', line 173 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::AuditLogSchema.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::AuditLogExport
Get Export
271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/workos/audit_logs.rb', line 271 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::AuditLogExport.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::AuditLogsRetention
Get Retention
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/workos/audit_logs.rb', line 29 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::AuditLogsRetention.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: 10, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AuditLogSchema>
List Schemas
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/workos/audit_logs.rb', line 127 def list_action_schemas( action_name:, before: nil, after: nil, limit: 10, 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::AuditLogSchema, filters: {action_name: action_name, before: before, limit: limit, order: order}, fetch_next: fetch_next ) end |
#list_actions(before: nil, after: nil, limit: 10, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AuditLogAction>
List Actions
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/workos/audit_logs.rb', line 82 def list_actions( before: nil, after: nil, limit: 10, 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::AuditLogAction, filters: {before: before, limit: limit, order: order}, fetch_next: fetch_next ) end |
#update_organization_audit_logs_retention(id:, retention:, request_options: {}) ⇒ WorkOS::AuditLogsRetention
Set Retention
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/workos/audit_logs.rb', line 49 def update_organization_audit_logs_retention( id:, retention:, request_options: {} ) body = {} case retention when WorkOS::AuditLogs::RetentionPeriod body["retention_period"] = retention.retention_period when WorkOS::AuditLogs::RetentionPeriodInDays body["retention_period_in_days"] = retention.retention_period_in_days else raise ArgumentError, "expected retention to be one of: WorkOS::AuditLogs::RetentionPeriod, WorkOS::AuditLogs::RetentionPeriodInDays, got #{retention.class}" end response = @client.request( method: :put, path: "/organizations/#{WorkOS::Util.encode_path(id)}/audit_logs_retention", auth: true, body: body, request_options: ) result = WorkOS::AuditLogsRetention.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 |