workos 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06fb7835303dcd8aa08c89cdd04c24c59f0d649b7e21d7dfd6ae82cc57529304
4
- data.tar.gz: 62bfacb18255d7c177c611c7dda0dd2a459610cdd1e0a0c48bbe3800a750ed64
3
+ metadata.gz: 2fae212aa830d1b7de8522d9886fa3081ac578981a3fe352a7fd31b4a2e0ca02
4
+ data.tar.gz: 189e54ee9cb6e86cae3f8754718a4c08034727a1f7ce9c6bcbcc272dd5e6b34e
5
5
  SHA512:
6
- metadata.gz: dd38c198e15b8c0f9f804593aba4eebe23ccad4c3be119c3d75861f0f38769fa13bccf204ad1085f74a32d448877e172eac4f45132fae8e4a793d699e0e78327
7
- data.tar.gz: de1017c20f88ad1ba4d74cb51e98a6f234e692564ef073ceaeaae893cdc3b70c2af9bce74d74264fe0461d21ce0757fc8e6548143de33a54a1dc9f08f8a91eab
6
+ metadata.gz: 816220f9a6b4dd3ba355ee7d94c343f5005b85cf91f7096f942e53cb2693fe8119981de1530269a04e456de16253f6d4205cf4410099723ff797b00caea724f9
7
+ data.tar.gz: 04713ab0a225047a0f9fab79ece78a14a873eb6b4e5a2bfc5b96f4555568a7ec13a0ebe7e2c4127cb929ecc34be9c73056c066be9edb52045119eaa8144dd928
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- workos (0.2.3)
4
+ workos (0.3.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.5560)
59
+ sorbet-runtime (0.5.5571)
60
60
  sorbet-static (0.5.5560-universal-darwin-14)
61
61
  unicode-display_width (1.6.0)
62
62
  url (0.3.2)
data/README.md CHANGED
@@ -80,7 +80,7 @@ WorkOS::AuditTrail.create_event(event: payload, idempotency_key: 'key123456')
80
80
  ```
81
81
 
82
82
  See our [API
83
- Reference](https://docs.workos.com/api-reference#idempotency)
83
+ Reference](https://docs.workos.com/audit-trail/api-reference#idempotency)
84
84
  for more information on idempotency keys.
85
85
 
86
86
  ## The SSO Module
data/lib/workos.rb CHANGED
@@ -30,6 +30,7 @@ module WorkOS
30
30
  autoload :Client, 'workos/client'
31
31
  autoload :AuditTrail, 'workos/audit_trail'
32
32
  autoload :Connection, 'workos/connection'
33
+ autoload :DirectorySync, 'workos/directory_sync'
33
34
  autoload :Profile, 'workos/profile'
34
35
  autoload :SSO, 'workos/sso'
35
36
 
@@ -0,0 +1,128 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+
4
+ module WorkOS
5
+ # The Directory Sync module provides convenience methods for working with the
6
+ # WorkOS Directory Sync platform. You'll need a valid API key and to have
7
+ # created a Directory Sync connection on your WorkOS dashboard.
8
+ #
9
+ # @see https://docs.workos.com/directory-sync/overview
10
+ module DirectorySync
11
+ class << self
12
+ extend T::Sig
13
+ include Base
14
+ include Client
15
+
16
+ # Retrieve directories.
17
+ #
18
+ # @param [Hash] options An options hash
19
+ # @option options [String] domain The domain of the directory to be
20
+ # retrieved.
21
+ # @option options [String] search A search term for direcory names.
22
+ #
23
+ # @return [Hash]
24
+ sig do
25
+ params(
26
+ options: T::Hash[Symbol, String],
27
+ ).returns(T::Array[T::Hash[String, T.nilable(String)]])
28
+ end
29
+ def list_directories(options = {})
30
+ response = execute_request(
31
+ request: get_request(
32
+ path: '/directories',
33
+ auth: true,
34
+ params: options,
35
+ ),
36
+ )
37
+
38
+ JSON.parse(response.body)['data']
39
+ end
40
+
41
+ # Retrieve directory groups.
42
+ #
43
+ # @param [Hash] options An options hash
44
+ # @option options [String] directory The ID of the directory whose
45
+ # directory groups will be retrieved.
46
+ # @option options [String] user The ID of the directory user whose
47
+ # directory groups will be retrieved.
48
+ #
49
+ # @return [Hash]
50
+ sig do
51
+ params(
52
+ options: T::Hash[Symbol, String],
53
+ ).returns(T::Array[T::Hash[String, T.nilable(String)]])
54
+ end
55
+ def list_groups(options = {})
56
+ response = execute_request(
57
+ request: get_request(
58
+ path: '/directory_groups',
59
+ auth: true,
60
+ params: options,
61
+ ),
62
+ )
63
+
64
+ JSON.parse(response.body)['data']
65
+ end
66
+
67
+ # Retrieve directory users.
68
+ #
69
+ # @param [Hash] options An options hash
70
+ # @option options [String] directory The ID of the directory whose
71
+ # directory users will be retrieved.
72
+ # @option options [String] user The ID of the directory group whose
73
+ # directory users will be retrieved.
74
+ #
75
+ # @return [Hash]
76
+ sig do
77
+ params(
78
+ options: T::Hash[Symbol, String],
79
+ ).returns(T::Array[T::Hash[String, T.untyped]])
80
+ end
81
+ def list_users(options = {})
82
+ response = execute_request(
83
+ request: get_request(
84
+ path: '/directory_users',
85
+ auth: true,
86
+ params: options,
87
+ ),
88
+ )
89
+
90
+ JSON.parse(response.body)['data']
91
+ end
92
+
93
+ # Retrieve the directory group with the given ID.
94
+ #
95
+ # @param [String] id The ID of the directory group.
96
+ #
97
+ # @return Hash
98
+ sig { params(id: String).returns(T::Hash[String, T.untyped]) }
99
+ def get_group(id)
100
+ response = execute_request(
101
+ request: get_request(
102
+ path: "/directory_groups/#{id}",
103
+ auth: true,
104
+ ),
105
+ )
106
+
107
+ JSON.parse(response.body)
108
+ end
109
+
110
+ # Retrieve the directory user with the given ID.
111
+ #
112
+ # @param [String] id The ID of the directory user.
113
+ #
114
+ # @return Hash
115
+ sig { params(id: String).returns(T::Hash[String, T.untyped]) }
116
+ def get_user(id)
117
+ response = execute_request(
118
+ request: get_request(
119
+ path: "/directory_users/#{id}",
120
+ auth: true,
121
+ ),
122
+ )
123
+
124
+ JSON.parse(response.body)
125
+ end
126
+ end
127
+ end
128
+ end
@@ -2,5 +2,5 @@
2
2
  # typed: strong
3
3
 
4
4
  module WorkOS
5
- VERSION = '0.2.3'
5
+ VERSION = '0.3.0'
6
6
  end
@@ -0,0 +1,139 @@
1
+ # frozen_string_literal: true
2
+ # typed: false
3
+
4
+ describe WorkOS::DirectorySync do
5
+ before(:all) do
6
+ WorkOS.key = 'key'
7
+ end
8
+
9
+ after(:all) do
10
+ WorkOS.key = nil
11
+ end
12
+
13
+ describe '.list_directories' do
14
+ context 'with no options' do
15
+ it 'returns directories' do
16
+ VCR.use_cassette('directory_sync/list_directories') do
17
+ directories = WorkOS::DirectorySync.list_directories
18
+ expect(directories.size).to eq(1)
19
+ end
20
+ end
21
+ end
22
+
23
+ context 'with domain option' do
24
+ it 'returns directories' do
25
+ VCR.use_cassette('directory_sync/list_directories_with_domain_param') do
26
+ directories = WorkOS::DirectorySync.list_directories(
27
+ domain: 'foo-corp.com',
28
+ )
29
+
30
+ expect(directories.first['domain']).to eq('foo-corp.com')
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ describe '.list_groups' do
37
+ context 'with no options' do
38
+ it 'returns groups' do
39
+ VCR.use_cassette('directory_sync/list_groups') do
40
+ expect do
41
+ WorkOS::DirectorySync.list_groups
42
+ end.to raise_error(
43
+ WorkOS::InvalidRequestError,
44
+ /Status 422, Validation failed/,
45
+ )
46
+ end
47
+ end
48
+ end
49
+
50
+ context 'with directory option' do
51
+ it 'returns groups' do
52
+ VCR.use_cassette('directory_sync/list_groups_with_directory_param') do
53
+ groups = WorkOS::DirectorySync.list_groups(
54
+ directory: 'directory_edp_01E64QQVQTCB0DECJ9CFNXEWDW',
55
+ )
56
+
57
+ expect(groups.size).to eq(2)
58
+ expect(groups.first['name']).to eq('Walrus')
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ describe '.list_users' do
65
+ context 'with no options' do
66
+ it 'returns users' do
67
+ VCR.use_cassette('directory_sync/list_users') do
68
+ expect do
69
+ WorkOS::DirectorySync.list_users
70
+ end.to raise_error(
71
+ WorkOS::InvalidRequestError,
72
+ /Status 422, Validation failed/,
73
+ )
74
+ end
75
+ end
76
+ end
77
+
78
+ context 'with directory option' do
79
+ it 'returns users' do
80
+ VCR.use_cassette('directory_sync/list_users_with_directory_param') do
81
+ users = WorkOS::DirectorySync.list_users(
82
+ directory: 'directory_edp_01E64QQVQTCB0DECJ9CFNXEWDW',
83
+ )
84
+
85
+ expect(users.size).to eq(1)
86
+ expect(users.first['last_name']).to eq('Tran')
87
+ end
88
+ end
89
+ end
90
+ end
91
+
92
+ describe '.get_group' do
93
+ context 'with valid id' do
94
+ it 'returns a group' do
95
+ VCR.use_cassette('directory_sync/get_group') do
96
+ group = WorkOS::DirectorySync.get_group(
97
+ 'directory_grp_01E64QTDNS0EGJ0FMCVY9BWGZT',
98
+ )
99
+
100
+ expect(group['name']).to eq('Walrus')
101
+ end
102
+ end
103
+ end
104
+
105
+ context 'with invalid id' do
106
+ it 'raises an error' do
107
+ VCR.use_cassette('directory_sync/get_group_with_invalid_id') do
108
+ expect do
109
+ WorkOS::DirectorySync.get_group('invalid')
110
+ end.to raise_error(WorkOS::APIError)
111
+ end
112
+ end
113
+ end
114
+ end
115
+
116
+ describe '.get_user' do
117
+ context 'with valid id' do
118
+ it 'returns a user' do
119
+ VCR.use_cassette('directory_sync/get_user') do
120
+ user = WorkOS::DirectorySync.get_user(
121
+ 'directory_usr_01E64QS50EAY48S0XJ1AA4WX4D',
122
+ )
123
+
124
+ expect(user['first_name']).to eq('Mark')
125
+ end
126
+ end
127
+ end
128
+
129
+ context 'with invalid id' do
130
+ it 'raises an error' do
131
+ VCR.use_cassette('directory_sync/get_user_with_invalid_id') do
132
+ expect do
133
+ WorkOS::DirectorySync.get_user('invalid')
134
+ end.to raise_error(WorkOS::APIError)
135
+ end
136
+ end
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.workos.com/directory_groups/directory_grp_01E64QTDNS0EGJ0FMCVY9BWGZT
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.2.3
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - Cowboy
27
+ Connection:
28
+ - keep-alive
29
+ Vary:
30
+ - Origin, Accept-Encoding
31
+ Access-Control-Allow-Credentials:
32
+ - 'true'
33
+ X-Dns-Prefetch-Control:
34
+ - 'off'
35
+ X-Frame-Options:
36
+ - SAMEORIGIN
37
+ Strict-Transport-Security:
38
+ - max-age=15552000; includeSubDomains
39
+ X-Download-Options:
40
+ - noopen
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ X-Xss-Protection:
44
+ - 1; mode=block
45
+ X-Request-Id:
46
+ - 4fb94ab3-ecff-4cea-b0b7-d4d1b3ffad3a
47
+ Content-Type:
48
+ - application/json; charset=utf-8
49
+ Content-Length:
50
+ - '65'
51
+ Etag:
52
+ - W/"41-QrnAKhorJuUwAsR1OyMpfB8q1Kc"
53
+ Date:
54
+ - Thu, 30 Apr 2020 04:47:49 GMT
55
+ Via:
56
+ - 1.1 vegur
57
+ body:
58
+ encoding: UTF-8
59
+ string: '{"id":"directory_grp_01E64QTDNS0EGJ0FMCVY9BWGZT","name":"Walrus"}'
60
+ http_version:
61
+ recorded_at: Thu, 30 Apr 2020 04:47:49 GMT
62
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.workos.com/directory_groups/invalid
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.2.3
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 404
23
+ message: Not Found
24
+ headers:
25
+ Server:
26
+ - Cowboy
27
+ Connection:
28
+ - keep-alive
29
+ Vary:
30
+ - Origin, Accept-Encoding
31
+ Access-Control-Allow-Credentials:
32
+ - 'true'
33
+ X-Dns-Prefetch-Control:
34
+ - 'off'
35
+ X-Frame-Options:
36
+ - SAMEORIGIN
37
+ Strict-Transport-Security:
38
+ - max-age=15552000; includeSubDomains
39
+ X-Download-Options:
40
+ - noopen
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ X-Xss-Protection:
44
+ - 1; mode=block
45
+ X-Request-Id:
46
+ - bbf92391-32bd-4d77-bbdc-0e77983d04d4
47
+ Content-Type:
48
+ - application/json; charset=utf-8
49
+ Content-Length:
50
+ - '23'
51
+ Etag:
52
+ - W/"17-SuRA/yvUWUo8rK6x7dKURLeBo+0"
53
+ Date:
54
+ - Thu, 30 Apr 2020 04:48:28 GMT
55
+ Via:
56
+ - 1.1 vegur
57
+ body:
58
+ encoding: UTF-8
59
+ string: '{"message":"Not Found"}'
60
+ http_version:
61
+ recorded_at: Thu, 30 Apr 2020 04:48:28 GMT
62
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.workos.com/directory_users/directory_usr_01E64QS50EAY48S0XJ1AA4WX4D
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.2.3
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - Cowboy
27
+ Connection:
28
+ - keep-alive
29
+ Vary:
30
+ - Origin, Accept-Encoding
31
+ Access-Control-Allow-Credentials:
32
+ - 'true'
33
+ X-Dns-Prefetch-Control:
34
+ - 'off'
35
+ X-Frame-Options:
36
+ - SAMEORIGIN
37
+ Strict-Transport-Security:
38
+ - max-age=15552000; includeSubDomains
39
+ X-Download-Options:
40
+ - noopen
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ X-Xss-Protection:
44
+ - 1; mode=block
45
+ X-Request-Id:
46
+ - fe3f582a-b944-4f2c-a225-ae3a7f099fa0
47
+ Content-Type:
48
+ - application/json; charset=utf-8
49
+ Content-Length:
50
+ - '368'
51
+ Etag:
52
+ - W/"170-JjGTDHa7GqXeAwXcua+s3+2z/oA"
53
+ Date:
54
+ - Thu, 30 Apr 2020 04:43:14 GMT
55
+ Via:
56
+ - 1.1 vegur
57
+ body:
58
+ encoding: UTF-8
59
+ string: '{"id":"directory_usr_01E64QS50EAY48S0XJ1AA4WX4D","raw_attributes":{"name":{"givenName":"Mark","familyName":"Tran"},"emails":[{"value":"mark@foo-corp.com","primary":true}],"userName":"mark@foo-corp.com","externalId":"118325297729072421906"},"first_name":"Mark","emails":[{"value":"mark@foo-corp.com","primary":true}],"username":"mark@foo-corp.com","last_name":"Tran"}'
60
+ http_version:
61
+ recorded_at: Thu, 30 Apr 2020 04:43:15 GMT
62
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.workos.com/directory_users/invalid
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.2.3
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 404
23
+ message: Not Found
24
+ headers:
25
+ Server:
26
+ - Cowboy
27
+ Connection:
28
+ - keep-alive
29
+ Vary:
30
+ - Origin, Accept-Encoding
31
+ Access-Control-Allow-Credentials:
32
+ - 'true'
33
+ X-Dns-Prefetch-Control:
34
+ - 'off'
35
+ X-Frame-Options:
36
+ - SAMEORIGIN
37
+ Strict-Transport-Security:
38
+ - max-age=15552000; includeSubDomains
39
+ X-Download-Options:
40
+ - noopen
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ X-Xss-Protection:
44
+ - 1; mode=block
45
+ X-Request-Id:
46
+ - 19dfa905-2015-44fb-8d5f-46f2d6c49826
47
+ Content-Type:
48
+ - application/json; charset=utf-8
49
+ Content-Length:
50
+ - '23'
51
+ Etag:
52
+ - W/"17-SuRA/yvUWUo8rK6x7dKURLeBo+0"
53
+ Date:
54
+ - Thu, 30 Apr 2020 04:45:35 GMT
55
+ Via:
56
+ - 1.1 vegur
57
+ body:
58
+ encoding: UTF-8
59
+ string: '{"message":"Not Found"}'
60
+ http_version:
61
+ recorded_at: Thu, 30 Apr 2020 04:45:35 GMT
62
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.workos.com/directories
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.2.3
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - Cowboy
27
+ Connection:
28
+ - keep-alive
29
+ Vary:
30
+ - Origin, Accept-Encoding
31
+ Access-Control-Allow-Credentials:
32
+ - 'true'
33
+ X-Dns-Prefetch-Control:
34
+ - 'off'
35
+ X-Frame-Options:
36
+ - SAMEORIGIN
37
+ Strict-Transport-Security:
38
+ - max-age=15552000; includeSubDomains
39
+ X-Download-Options:
40
+ - noopen
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ X-Xss-Protection:
44
+ - 1; mode=block
45
+ X-Request-Id:
46
+ - 53c53a76-1f3f-43bb-85a3-8faef43db375
47
+ Content-Type:
48
+ - application/json; charset=utf-8
49
+ Etag:
50
+ - W/"b53-vfsK4+PwHsj4f+pAs0MzdO3odVo"
51
+ Date:
52
+ - Thu, 30 Apr 2020 03:11:45 GMT
53
+ Transfer-Encoding:
54
+ - chunked
55
+ Via:
56
+ - 1.1 vegur
57
+ body:
58
+ encoding: ASCII-8BIT
59
+ string: '{"object":"list","listMetadata":{"before":"directory_edp_01E44H95QPBGZ6A4D89VYZ0WX1","after":null},"data":[{"object":"directory","id":"directory_edp_01E64QQVQTCB0DECJ9CFNXEWDW","external_key":"lA3gS1kCZMCkk82E","state":"linked","type":"gsuite directory","name":"Foo Corp","bearer_token":null,"project_id":"project_01DFYCG8RCB1DB6DKFTGXF4Q9F","domain":"foo-corp.com"}]}'
60
+ http_version:
61
+ recorded_at: Thu, 30 Apr 2020 03:11:45 GMT
62
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,63 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.workos.com/directories?domain=foo-corp.com
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.2.3
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - Cowboy
27
+ Connection:
28
+ - keep-alive
29
+ Vary:
30
+ - Origin, Accept-Encoding
31
+ Access-Control-Allow-Credentials:
32
+ - 'true'
33
+ X-Dns-Prefetch-Control:
34
+ - 'off'
35
+ X-Frame-Options:
36
+ - SAMEORIGIN
37
+ Strict-Transport-Security:
38
+ - max-age=15552000; includeSubDomains
39
+ X-Download-Options:
40
+ - noopen
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ X-Xss-Protection:
44
+ - 1; mode=block
45
+ X-Request-Id:
46
+ - '08feb93b-22e8-4955-b17d-0e5efa1ed6a4'
47
+ Content-Type:
48
+ - application/json; charset=utf-8
49
+ Content-Length:
50
+ - '330'
51
+ Etag:
52
+ - W/"14a-Q+U+kuKWjl8FQwSosUsvUraY82A"
53
+ Date:
54
+ - Thu, 30 Apr 2020 03:42:20 GMT
55
+ Via:
56
+ - 1.1 vegur
57
+ body:
58
+ encoding: UTF-8
59
+ string: '{"object":"list","listMetadata":{"before":null,"after":null},"data":[{"object":"directory","id":"directory_edp_01E64QQVQTCB0DECJ9CFNXEWDW","external_key":"lA3gS1kCZMCkk82E","state":"linked","type":"gsuite
60
+ directory","name":"Foo Corp","bearer_token":null,"project_id":"project_01DFYCG8RCB1DB6DKFTGXF4Q9F","domain":"foo-corp.com"}]}'
61
+ http_version:
62
+ recorded_at: Thu, 30 Apr 2020 03:42:20 GMT
63
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,64 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.workos.com/directory_groups
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.2.3
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 422
23
+ message: Unprocessable Entity
24
+ headers:
25
+ Server:
26
+ - Cowboy
27
+ Connection:
28
+ - keep-alive
29
+ Vary:
30
+ - Origin, Accept-Encoding
31
+ Access-Control-Allow-Credentials:
32
+ - 'true'
33
+ X-Dns-Prefetch-Control:
34
+ - 'off'
35
+ X-Frame-Options:
36
+ - SAMEORIGIN
37
+ Strict-Transport-Security:
38
+ - max-age=15552000; includeSubDomains
39
+ X-Download-Options:
40
+ - noopen
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ X-Xss-Protection:
44
+ - 1; mode=block
45
+ X-Request-Id:
46
+ - 3ffb5dc0-7dbe-453f-9514-6e50363b413e
47
+ Content-Type:
48
+ - application/json; charset=utf-8
49
+ Content-Length:
50
+ - '219'
51
+ Etag:
52
+ - W/"db-gphk1TAe8P3eXtQnl1v8qxKQjZs"
53
+ Date:
54
+ - Thu, 30 Apr 2020 06:24:08 GMT
55
+ Via:
56
+ - 1.1 vegur
57
+ body:
58
+ encoding: UTF-8
59
+ string: '{"message":"Validation failed","errors":[{"field":"directory","code":"Please
60
+ provide either \"directory\" or \"user\" parameters."},{"field":"user","code":"Please
61
+ provide either \"directory\" or \"user\" parameters."}]}'
62
+ http_version:
63
+ recorded_at: Thu, 30 Apr 2020 06:24:08 GMT
64
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.workos.com/directory_groups?directory=directory_edp_01E64QQVQTCB0DECJ9CFNXEWDW
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.2.3
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - Cowboy
27
+ Connection:
28
+ - keep-alive
29
+ Vary:
30
+ - Origin, Accept-Encoding
31
+ Access-Control-Allow-Credentials:
32
+ - 'true'
33
+ X-Dns-Prefetch-Control:
34
+ - 'off'
35
+ X-Frame-Options:
36
+ - SAMEORIGIN
37
+ Strict-Transport-Security:
38
+ - max-age=15552000; includeSubDomains
39
+ X-Download-Options:
40
+ - noopen
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ X-Xss-Protection:
44
+ - 1; mode=block
45
+ X-Request-Id:
46
+ - 87133408-9847-42ef-a6da-183280e6402c
47
+ Content-Type:
48
+ - application/json; charset=utf-8
49
+ Content-Length:
50
+ - '813'
51
+ Etag:
52
+ - W/"32d-Pi2S8kCjmY/SVPoMmwh0JNvHbgY"
53
+ Date:
54
+ - Thu, 30 Apr 2020 04:31:47 GMT
55
+ Via:
56
+ - 1.1 vegur
57
+ body:
58
+ encoding: UTF-8
59
+ string: '{"object":"list","listMetadata":{"before":"directory_grp_01E64QTDHHE80V9N03ZTDV5SXD","after":null},"data":[{"id":"directory_grp_01E64QTDNS0EGJ0FMCVY9BWGZT","name":"Walrus"},{"id":"directory_grp_01E64QTDJTE8P0S3JKM7KV848A","name":"Design team"}]}'
60
+ http_version:
61
+ recorded_at: Thu, 30 Apr 2020 04:31:47 GMT
62
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,64 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.workos.com/directory_users
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.2.3
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 422
23
+ message: Unprocessable Entity
24
+ headers:
25
+ Server:
26
+ - Cowboy
27
+ Connection:
28
+ - keep-alive
29
+ Vary:
30
+ - Origin, Accept-Encoding
31
+ Access-Control-Allow-Credentials:
32
+ - 'true'
33
+ X-Dns-Prefetch-Control:
34
+ - 'off'
35
+ X-Frame-Options:
36
+ - SAMEORIGIN
37
+ Strict-Transport-Security:
38
+ - max-age=15552000; includeSubDomains
39
+ X-Download-Options:
40
+ - noopen
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ X-Xss-Protection:
44
+ - 1; mode=block
45
+ X-Request-Id:
46
+ - 67a36a16-8d82-495d-a4cd-11a42e6c111e
47
+ Content-Type:
48
+ - application/json; charset=utf-8
49
+ Content-Length:
50
+ - '222'
51
+ Etag:
52
+ - W/"de-33B+CY27z2HlOGKZPu4nzUVQpuI"
53
+ Date:
54
+ - Thu, 30 Apr 2020 06:23:44 GMT
55
+ Via:
56
+ - 1.1 vegur
57
+ body:
58
+ encoding: UTF-8
59
+ string: '{"message":"Validation failed","errors":[{"field":"directory","code":"Please
60
+ provide either \"directory\" or \"group\" parameters."},{"field":"group","code":"Please
61
+ provide either \"directory\" or \"group\" parameters."}]}'
62
+ http_version:
63
+ recorded_at: Thu, 30 Apr 2020 06:23:44 GMT
64
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.workos.com/directory_users?directory=directory_edp_01E64QQVQTCB0DECJ9CFNXEWDW
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.2.3
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - Cowboy
27
+ Connection:
28
+ - keep-alive
29
+ Vary:
30
+ - Origin, Accept-Encoding
31
+ Access-Control-Allow-Credentials:
32
+ - 'true'
33
+ X-Dns-Prefetch-Control:
34
+ - 'off'
35
+ X-Frame-Options:
36
+ - SAMEORIGIN
37
+ Strict-Transport-Security:
38
+ - max-age=15552000; includeSubDomains
39
+ X-Download-Options:
40
+ - noopen
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ X-Xss-Protection:
44
+ - 1; mode=block
45
+ X-Request-Id:
46
+ - 91802a43-3053-41e6-9a71-44fe88321224
47
+ Content-Type:
48
+ - application/json; charset=utf-8
49
+ Etag:
50
+ - W/"e55-P0NG6CugY3cr6/bL+B4xBkwDGns"
51
+ Date:
52
+ - Thu, 30 Apr 2020 04:36:02 GMT
53
+ Transfer-Encoding:
54
+ - chunked
55
+ Via:
56
+ - 1.1 vegur
57
+ body:
58
+ encoding: ASCII-8BIT
59
+ string: '{"object":"list","listMetadata":{"before":null,"after":null},"data":[{"id":"directory_usr_01E64QS50EAY48S0XJ1AA4WX4D","raw_attributes":{"name":{"givenName":"Mark","familyName":"Tran"},"emails":[{"value":"mark@foo-corp.com","primary":true}],"userName":"mark@foo-corp.com","externalId":"118325297729072421906"},"first_name":"Mark","emails":[{"value":"mark@foo-corp.com","primary":true}],"username":"mark@foo-corp.com","last_name":"Tran"}]}'
60
+ http_version:
61
+ recorded_at: Thu, 30 Apr 2020 04:36:02 GMT
62
+ 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.2.3
4
+ version: 0.3.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-04-24 00:00:00.000000000 Z
11
+ date: 2020-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorbet-runtime
@@ -211,6 +211,7 @@ files:
211
211
  - lib/workos/base.rb
212
212
  - lib/workos/client.rb
213
213
  - lib/workos/connection.rb
214
+ - lib/workos/directory_sync.rb
214
215
  - lib/workos/errors.rb
215
216
  - lib/workos/profile.rb
216
217
  - lib/workos/sso.rb
@@ -230,6 +231,7 @@ files:
230
231
  - sorbet/rbi/todo.rbi
231
232
  - spec/lib/workos/audit_trail_spec.rb
232
233
  - spec/lib/workos/base_spec.rb
234
+ - spec/lib/workos/directory_sync_spec.rb
233
235
  - spec/lib/workos/sso_spec.rb
234
236
  - spec/spec_helper.rb
235
237
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_event.yml
@@ -238,6 +240,16 @@ files:
238
240
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_events_duplicate_idempotency_key_and_payload.yml
239
241
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_events_duplicate_idempotency_key_different_payload.yml
240
242
  - spec/support/fixtures/vcr_cassettes/base/execute_request_unauthenticated.yml
243
+ - spec/support/fixtures/vcr_cassettes/directory_sync/get_group.yml
244
+ - spec/support/fixtures/vcr_cassettes/directory_sync/get_group_with_invalid_id.yml
245
+ - spec/support/fixtures/vcr_cassettes/directory_sync/get_user.yml
246
+ - spec/support/fixtures/vcr_cassettes/directory_sync/get_user_with_invalid_id.yml
247
+ - spec/support/fixtures/vcr_cassettes/directory_sync/list_directories.yml
248
+ - spec/support/fixtures/vcr_cassettes/directory_sync/list_directories_with_domain_param.yml
249
+ - spec/support/fixtures/vcr_cassettes/directory_sync/list_groups.yml
250
+ - spec/support/fixtures/vcr_cassettes/directory_sync/list_groups_with_directory_param.yml
251
+ - spec/support/fixtures/vcr_cassettes/directory_sync/list_users.yml
252
+ - spec/support/fixtures/vcr_cassettes/directory_sync/list_users_with_directory_param.yml
241
253
  - spec/support/fixtures/vcr_cassettes/sso/create_connection_with_invalid_source.yml
242
254
  - spec/support/fixtures/vcr_cassettes/sso/create_connection_with_valid_source.yml
243
255
  - spec/support/profile.txt
@@ -268,6 +280,7 @@ summary: API client for WorkOS
268
280
  test_files:
269
281
  - spec/lib/workos/audit_trail_spec.rb
270
282
  - spec/lib/workos/base_spec.rb
283
+ - spec/lib/workos/directory_sync_spec.rb
271
284
  - spec/lib/workos/sso_spec.rb
272
285
  - spec/spec_helper.rb
273
286
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_event.yml
@@ -276,6 +289,16 @@ test_files:
276
289
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_events_duplicate_idempotency_key_and_payload.yml
277
290
  - spec/support/fixtures/vcr_cassettes/audit_trail/create_events_duplicate_idempotency_key_different_payload.yml
278
291
  - spec/support/fixtures/vcr_cassettes/base/execute_request_unauthenticated.yml
292
+ - spec/support/fixtures/vcr_cassettes/directory_sync/get_group.yml
293
+ - spec/support/fixtures/vcr_cassettes/directory_sync/get_group_with_invalid_id.yml
294
+ - spec/support/fixtures/vcr_cassettes/directory_sync/get_user.yml
295
+ - spec/support/fixtures/vcr_cassettes/directory_sync/get_user_with_invalid_id.yml
296
+ - spec/support/fixtures/vcr_cassettes/directory_sync/list_directories.yml
297
+ - spec/support/fixtures/vcr_cassettes/directory_sync/list_directories_with_domain_param.yml
298
+ - spec/support/fixtures/vcr_cassettes/directory_sync/list_groups.yml
299
+ - spec/support/fixtures/vcr_cassettes/directory_sync/list_groups_with_directory_param.yml
300
+ - spec/support/fixtures/vcr_cassettes/directory_sync/list_users.yml
301
+ - spec/support/fixtures/vcr_cassettes/directory_sync/list_users_with_directory_param.yml
279
302
  - spec/support/fixtures/vcr_cassettes/sso/create_connection_with_invalid_source.yml
280
303
  - spec/support/fixtures/vcr_cassettes/sso/create_connection_with_valid_source.yml
281
304
  - spec/support/profile.txt