workos 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 773cbb5edfa2433922650417a8b487513bc197fa72b758fd4423bea67bf87f49
4
- data.tar.gz: 72f573248a97132d57117718e811242b6be36ad15025eeec9f311a3477186bf4
3
+ metadata.gz: ce58ab479d49e4f828ebe675fb3f3b8104a6d82d85f19da6087f9a907dc1e827
4
+ data.tar.gz: 96d0c77cf047d6e56952414cda3d80d2395b692b4125af95c15a9ba85b00c0c9
5
5
  SHA512:
6
- metadata.gz: 4fe620f43ec9b30ed8a885c08d157bfc5f0da091d820306fcba3e9dee9ba7b6d69d3f5b5cad8b74882a3080058ede66da47af228c2ccd761715ee4c8a7d82eac
7
- data.tar.gz: 442b32e6bdc38579e21937c7da371d4b6f767027c021620f538d468d0e8ac9ca31cd226778c7b5f10f419f3d1c0d21cb402e846738abd871a67c95ac315130d4
6
+ metadata.gz: 8529507b9187453055b084ec30446123a2572f4045380f17916d640b1c0f052eb64089d620695469b3eb0839c3d88e4f6827a24de1802bd432f2c5f134cb3094
7
+ data.tar.gz: 505133b5a111f5efdfd1b9c26b773f6359dc21841273df43ae0f7090afec8ee11350830004f2dd285d7b607b3d423e95513c50484cab36ade8be60686be214f1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- workos (0.3.3)
4
+ workos (0.4.0)
5
5
  sorbet-runtime (~> 0.5)
6
6
 
7
7
  GEM
@@ -56,7 +56,7 @@ GEM
56
56
  simplecov-html (0.10.2)
57
57
  sorbet (0.5.5560)
58
58
  sorbet-static (= 0.5.5560)
59
- sorbet-runtime (0.5.5815)
59
+ sorbet-runtime (0.5.5858)
60
60
  sorbet-static (0.5.5560-universal-darwin-14)
61
61
  unicode-display_width (1.6.0)
62
62
  url (0.3.2)
@@ -57,6 +57,54 @@ module WorkOS
57
57
 
58
58
  execute_request(request: request)
59
59
  end
60
+
61
+ # Retrieve Audit Trail events.
62
+ #
63
+ # @param [Hash] options An options hash
64
+ # @option options [String] before Event ID to look before
65
+ # @option options [String] after Event ID to look after
66
+ # @option options [Integer] limit Number of Events to return
67
+ # @option options [Array<String>] group List of Groups to filter for
68
+ # @option options [Array<String>] action List of Actions to filter for
69
+ # @option options [Array<String>] action_type List of Action Types to
70
+ # filter for
71
+ # @option options [Array<String>] actor_name List of Actor Name to filter
72
+ # for
73
+ # @option options [Array<String>] actor_id List of Actor IDs to filter for
74
+ # @option options [Array<String>] target_name List of Target Names to
75
+ # filter for
76
+ # @option options [Array<String>] target_id List of Target IDs to filter
77
+ # for
78
+ # @option options [String] occurred_at ISO-8601 datetime of when an event
79
+ # occurred
80
+ # @option options [String] occurred_at_gt ISO-8601 datetime of when an
81
+ # event occurred after
82
+ # @option options [String] occurred_at_gte ISO-8601 datetime of when an
83
+ # event occurred at or after
84
+ # @option options [String] occurred_at_lt ISO-8601 datetime of when an
85
+ # event occurred before
86
+ # @option options [String] ISO-8601 datetime of when an event occured at
87
+ # or before
88
+ # @option options [String] search Keyword search
89
+ #
90
+ # @return [Array<Hash>]
91
+ sig do
92
+ params(
93
+ options: T::Hash[Symbol, String],
94
+ ).returns(T::Array[T::Hash[String, T.nilable(String)]])
95
+ end
96
+
97
+ def get_events(options = {})
98
+ response = execute_request(
99
+ request: get_request(
100
+ path: '/events',
101
+ auth: true,
102
+ params: options,
103
+ ),
104
+ )
105
+
106
+ JSON.parse(response.body)['data']
107
+ end
60
108
  end
61
109
  end
62
110
  end
@@ -2,5 +2,5 @@
2
2
  # typed: strong
3
3
 
4
4
  module WorkOS
5
- VERSION = '0.3.3'
5
+ VERSION = '0.4.0'
6
6
  end
@@ -137,4 +137,16 @@ describe WorkOS::AuditTrail do
137
137
  end
138
138
  end
139
139
  end
140
+
141
+ describe '.get_events' do
142
+ context 'with no options' do
143
+ it 'returns events' do
144
+ VCR.use_cassette('audit_trail/get_events') do
145
+ events = described_class.get_events
146
+
147
+ expect(events.size).to eq(2)
148
+ end
149
+ end
150
+ end
151
+ end
140
152
  end
@@ -0,0 +1,61 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.workos.com/events
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ""
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ User-Agent:
17
+ - WorkOS; ruby/2.7.1; x86_64-darwin19; v0.4.0
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Vary:
26
+ - Origin, Accept-Encoding
27
+ Access-Control-Allow-Credentials:
28
+ - "true"
29
+ X-Dns-Prefetch-Control:
30
+ - "off"
31
+ X-Frame-Options:
32
+ - SAMEORIGIN
33
+ Strict-Transport-Security:
34
+ - max-age=15552000; includeSubDomains
35
+ X-Download-Options:
36
+ - noopen
37
+ X-Content-Type-Options:
38
+ - nosniff
39
+ X-Xss-Protection:
40
+ - 1; mode=block
41
+ X-Request-Id:
42
+ - ""
43
+ Content-Type:
44
+ - application/json; charset=utf-8
45
+ Etag:
46
+ - W/"1784-HtVN7X+AT30Dlt9nZrirP0nnyV8"
47
+ Date:
48
+ - Fri, 31 Jul 2020 14:41:12 GMT
49
+ Connection:
50
+ - keep-alive
51
+ Transfer-Encoding:
52
+ - chunked
53
+ body:
54
+ encoding: ASCII-8BIT
55
+ string:
56
+ '{"data":[{"object":"event","id":"evt_01EEJM9Q9SMC3W2SZDKA5VJ8XQ","group":"workos.com","location":"::1","latitude":null,"longitude":null,"type":"r","actor_name":"foo@example.com","actor_id":"user_01EEG9P7A1DA9VY9CX7GT47RPF","target_name":"api_key_query","target_id":"key_01EEG9MPHAYX46BBZKGK3BGQXJ","metadata":{"description":"User
57
+ viewed API key.","x_request_id":""},"occurred_at":"2020-07-31T14:27:00.384Z","action":{"object":"event_action","id":"evt_action_01EEGQXWAHB065P5JD0QDAAGDC","name":"user.viewed_api_key","project_id":"project_01DZB0E7HQMA6G85PQNHQJMZD0"}},{"object":"event","id":"evt_01EEJM9Q7GMR1VGT6VXN2N2JJQ","group":"workos.com","location":"::1","latitude":null,"longitude":null,"type":"r","actor_name":"foo@example.com","actor_id":"user_01EEG9P7A1DA9VY9CX7GT47RPF","target_name":"api_key_query","target_id":"key_01EEG9MPGM8KFT9VBQHJMV8YZB","metadata":{"description":"User
58
+ viewed API key.","x_request_id":""},"occurred_at":"2020-07-31T14:27:00.360Z","action":{"object":"event_action","id":"evt_action_01EEGQXWAHB065P5JD0QDAAGDC","name":"user.viewed_api_key","project_id":"project_01DZB0E7HQMA6G85PQNHQJMZD0"}}],"listMetadata":{"before":"evt_01EEJKZDAR6G4JHFQT4R3KSZDQ","after":null}}'
59
+ http_version:
60
+ recorded_at: Fri, 31 Jul 2020 14:41:12 GMT
61
+ recorded_with: VCR 5.0.0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - WorkOS
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-14 00:00:00.000000000 Z
11
+ date: 2020-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorbet-runtime
@@ -239,6 +239,7 @@ files:
239
239
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_event_invalid.yml
240
240
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_events_duplicate_idempotency_key_and_payload.yml
241
241
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_events_duplicate_idempotency_key_different_payload.yml
242
+ - spec/support/fixtures/vcr_cassettes/audit_trail/get_events.yml
242
243
  - spec/support/fixtures/vcr_cassettes/base/execute_request_unauthenticated.yml
243
244
  - spec/support/fixtures/vcr_cassettes/directory_sync/get_group.yml
244
245
  - spec/support/fixtures/vcr_cassettes/directory_sync/get_group_with_invalid_id.yml
@@ -289,6 +290,7 @@ test_files:
289
290
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_event_invalid.yml
290
291
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_events_duplicate_idempotency_key_and_payload.yml
291
292
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_events_duplicate_idempotency_key_different_payload.yml
293
+ - spec/support/fixtures/vcr_cassettes/audit_trail/get_events.yml
292
294
  - spec/support/fixtures/vcr_cassettes/base/execute_request_unauthenticated.yml
293
295
  - spec/support/fixtures/vcr_cassettes/directory_sync/get_group.yml
294
296
  - spec/support/fixtures/vcr_cassettes/directory_sync/get_group_with_invalid_id.yml