workos 7.1.1 → 8.0.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 +4 -4
- data/.github/workflows/docs.yml +46 -0
- data/.gitignore +2 -0
- data/.last-synced-sha +1 -1
- data/.oagen-manifest.json +61 -40
- data/.release-please-manifest.json +1 -1
- data/.yardopts +6 -0
- data/CHANGELOG.md +38 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +33 -2
- data/lib/workos/api_keys/api_key.rb +1 -1
- data/lib/workos/api_keys/api_key_created_data.rb +1 -1
- data/lib/workos/api_keys/organization_api_key.rb +43 -0
- data/lib/workos/{types/events_order.rb → api_keys/organization_api_key_owner.rb} +1 -3
- data/lib/workos/api_keys/organization_api_key_with_value.rb +46 -0
- data/lib/workos/{types/audit_logs_order.rb → api_keys/organization_api_key_with_value_owner.rb} +1 -3
- data/lib/workos/api_keys.rb +46 -46
- data/lib/workos/audit_logs.rb +6 -6
- data/lib/workos/authorization/user_organization_membership_base_list_data.rb +5 -2
- data/lib/workos/authorization/{role_assignment.rb → user_role_assignment.rb} +5 -2
- data/lib/workos/authorization/{role_assignment_resource.rb → user_role_assignment_resource.rb} +1 -1
- data/lib/workos/authorization.rb +250 -138
- data/lib/workos/base_client.rb +6 -1
- data/lib/workos/client.rb +4 -4
- data/lib/workos/connect.rb +2 -2
- data/lib/workos/directory_sync/directory_user.rb +3 -0
- data/lib/workos/directory_sync/directory_user_with_groups.rb +4 -1
- data/lib/workos/directory_sync/dsync_user_updated_data.rb +3 -0
- data/lib/workos/directory_sync.rb +6 -6
- data/lib/workos/encryptors/aes_gcm.rb +35 -3
- data/lib/workos/events.rb +2 -2
- data/lib/workos/feature_flags.rb +6 -6
- data/lib/workos/groups.rb +5 -5
- data/lib/workos/multi_factor_auth.rb +3 -3
- data/lib/workos/organization_domains.rb +1 -1
- data/lib/workos/organizations.rb +2 -2
- data/lib/workos/radar.rb +2 -2
- data/lib/workos/sso/profile.rb +3 -0
- data/lib/workos/sso.rb +4 -4
- data/lib/workos/types/event_context_actor_source.rb +2 -1
- data/lib/workos/types/{applications_order.rb → pagination_order.rb} +1 -1
- data/lib/workos/types/{vault_byok_key_verification_completed_data_key_provider.rb → vault_byok_key_provider.rb} +1 -1
- data/lib/workos/user_management/create_user_api_key.rb +25 -0
- data/lib/workos/user_management/organization_membership.rb +5 -2
- data/lib/workos/user_management/user_api_key.rb +43 -0
- data/lib/workos/user_management/user_api_key_created_data_owner.rb +25 -0
- data/lib/workos/{api_keys/api_key_with_value_owner.rb → user_management/user_api_key_owner.rb} +1 -1
- data/lib/workos/{types/webhooks_order.rb → user_management/user_api_key_revoked_data_owner.rb} +1 -3
- data/lib/workos/{api_keys/api_key_with_value.rb → user_management/user_api_key_with_value.rb} +2 -2
- data/lib/workos/{types/groups_order.rb → user_management/user_api_key_with_value_owner.rb} +1 -3
- data/lib/workos/user_management/user_organization_membership.rb +5 -2
- data/lib/workos/user_management.rb +181 -75
- data/lib/workos/user_management_organization_membership_groups.rb +2 -2
- data/lib/workos/vault/vault_byok_key_deleted.rb +34 -0
- data/lib/workos/vault/vault_byok_key_deleted_data.rb +22 -0
- data/lib/workos/version.rb +1 -1
- data/lib/workos/webhooks.rb +3 -3
- data/rbi/workos/api_key.rbi +2 -2
- data/rbi/workos/api_key_created_data.rbi +2 -2
- data/rbi/workos/api_key_revoked_data.rbi +2 -2
- data/rbi/workos/api_keys.rbi +17 -17
- data/rbi/workos/authorization.rbi +127 -27
- data/rbi/workos/client.rbi +3 -3
- data/rbi/workos/create_user_api_key.rbi +36 -0
- data/rbi/workos/directory_user.rbi +6 -0
- data/rbi/workos/directory_user_with_groups.rbi +6 -0
- data/rbi/workos/dsync_user_updated_data.rbi +6 -0
- data/rbi/workos/organization_api_key.rbi +72 -0
- data/rbi/workos/{api_key_with_value_owner.rbi → organization_api_key_owner.rbi} +1 -1
- data/rbi/workos/organization_api_key_with_value.rbi +78 -0
- data/rbi/workos/organization_api_key_with_value_owner.rbi +30 -0
- data/rbi/workos/organization_membership.rbi +6 -0
- data/rbi/workos/profile.rbi +6 -0
- data/rbi/workos/user_api_key.rbi +72 -0
- data/rbi/workos/user_api_key_created_data_owner.rbi +36 -0
- data/rbi/workos/user_api_key_owner.rbi +36 -0
- data/rbi/workos/user_api_key_revoked_data_owner.rbi +36 -0
- data/rbi/workos/{api_key_with_value.rbi → user_api_key_with_value.rbi} +3 -3
- data/rbi/workos/user_api_key_with_value_owner.rbi +36 -0
- data/rbi/workos/user_management.rbi +91 -14
- data/rbi/workos/user_organization_membership.rbi +6 -0
- data/rbi/workos/user_organization_membership_base_list_data.rbi +6 -0
- data/rbi/workos/{role_assignment.rbi → user_role_assignment.rbi} +9 -3
- data/rbi/workos/{role_assignment_resource.rbi → user_role_assignment_resource.rbi} +1 -1
- data/rbi/workos/vault_byok_key_deleted.rbi +54 -0
- data/rbi/workos/vault_byok_key_deleted_data.rbi +30 -0
- data/script/docs +16 -0
- data/script/docs-serve +12 -0
- data/script/llms-txt +37 -0
- data/test/workos/test_api_keys.rb +17 -17
- data/test/workos/test_audit_logs.rb +2 -2
- data/test/workos/test_authorization.rb +102 -20
- data/test/workos/test_encryptors_aes_gcm.rb +21 -0
- data/test/workos/test_model_round_trip.rb +278 -83
- data/test/workos/test_session.rb +68 -0
- data/test/workos/test_user_management.rb +69 -9
- data/test/workos/test_webhooks.rb +2 -2
- metadata +39 -33
- data/lib/workos/types/authorization_order.rb +0 -9
- data/lib/workos/types/connections_order.rb +0 -9
- data/lib/workos/types/directories_order.rb +0 -9
- data/lib/workos/types/directory_groups_order.rb +0 -9
- data/lib/workos/types/directory_users_order.rb +0 -9
- data/lib/workos/types/feature_flags_order.rb +0 -9
- data/lib/workos/types/organizations_api_keys_order.rb +0 -9
- data/lib/workos/types/organizations_feature_flags_order.rb +0 -9
- data/lib/workos/types/organizations_order.rb +0 -9
- data/lib/workos/types/permissions_order.rb +0 -9
- data/lib/workos/types/user_management_invitations_order.rb +0 -9
- data/lib/workos/types/user_management_multi_factor_authentication_order.rb +0 -9
- data/lib/workos/types/user_management_organization_membership_groups_order.rb +0 -9
- data/lib/workos/types/user_management_organization_membership_order.rb +0 -9
- data/lib/workos/types/user_management_users_authorized_applications_order.rb +0 -9
- data/lib/workos/types/user_management_users_feature_flags_order.rb +0 -9
- data/lib/workos/types/user_management_users_order.rb +0 -9
data/lib/workos/authorization.rb
CHANGED
|
@@ -6,6 +6,48 @@ require "json"
|
|
|
6
6
|
|
|
7
7
|
module WorkOS
|
|
8
8
|
class Authorization
|
|
9
|
+
# Identifies the resource target (by id variant).
|
|
10
|
+
#
|
|
11
|
+
# @!attribute [r] resource_id
|
|
12
|
+
# @return [String]
|
|
13
|
+
ResourceTargetById = Data.define(:resource_id)
|
|
14
|
+
|
|
15
|
+
# Identifies the resource target (by external id variant).
|
|
16
|
+
#
|
|
17
|
+
# @!attribute [r] resource_external_id
|
|
18
|
+
# @return [String]
|
|
19
|
+
# @!attribute [r] resource_type_slug
|
|
20
|
+
# @return [String]
|
|
21
|
+
ResourceTargetByExternalId = Data.define(:resource_external_id, :resource_type_slug)
|
|
22
|
+
|
|
23
|
+
# Identifies the parent resource (by id variant).
|
|
24
|
+
#
|
|
25
|
+
# @!attribute [r] parent_resource_id
|
|
26
|
+
# @return [String]
|
|
27
|
+
ParentResourceById = Data.define(:parent_resource_id)
|
|
28
|
+
|
|
29
|
+
# Identifies the parent resource (by external id variant).
|
|
30
|
+
#
|
|
31
|
+
# @!attribute [r] parent_resource_type_slug
|
|
32
|
+
# @return [String]
|
|
33
|
+
# @!attribute [r] parent_resource_external_id
|
|
34
|
+
# @return [String]
|
|
35
|
+
ParentResourceByExternalId = Data.define(:parent_resource_type_slug, :parent_resource_external_id)
|
|
36
|
+
|
|
37
|
+
# Identifies the parent (by id variant).
|
|
38
|
+
#
|
|
39
|
+
# @!attribute [r] parent_resource_id
|
|
40
|
+
# @return [String]
|
|
41
|
+
ParentById = Data.define(:parent_resource_id)
|
|
42
|
+
|
|
43
|
+
# Identifies the parent (by external id variant).
|
|
44
|
+
#
|
|
45
|
+
# @!attribute [r] parent_resource_type_slug
|
|
46
|
+
# @return [String]
|
|
47
|
+
# @!attribute [r] parent_external_id
|
|
48
|
+
# @return [String]
|
|
49
|
+
ParentByExternalId = Data.define(:parent_resource_type_slug, :parent_external_id)
|
|
50
|
+
|
|
9
51
|
def initialize(client)
|
|
10
52
|
@client = client
|
|
11
53
|
end
|
|
@@ -13,32 +55,26 @@ module WorkOS
|
|
|
13
55
|
# Check authorization
|
|
14
56
|
# @param organization_membership_id [String] The ID of the organization membership to check.
|
|
15
57
|
# @param permission_slug [String] The slug of the permission to check.
|
|
16
|
-
# @param
|
|
17
|
-
# @param resource_external_id [String, nil] The external ID of the resource. Required with `resource_type_slug`. Mutually exclusive with `resource_id`.
|
|
18
|
-
# @param resource_type_slug [String, nil] The slug of the resource type. Required with `resource_external_id`. Mutually exclusive with `resource_id`.
|
|
58
|
+
# @param resource_target [WorkOS::Authorization::ResourceTargetById, WorkOS::Authorization::ResourceTargetByExternalId] Identifies the resource target.
|
|
19
59
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
20
60
|
# @return [WorkOS::AuthorizationCheck]
|
|
21
61
|
def check(
|
|
22
62
|
organization_membership_id:,
|
|
23
63
|
permission_slug:,
|
|
24
64
|
resource_target:,
|
|
25
|
-
resource_id: nil,
|
|
26
|
-
resource_external_id: nil,
|
|
27
|
-
resource_type_slug: nil,
|
|
28
65
|
request_options: {}
|
|
29
66
|
)
|
|
30
67
|
body = {
|
|
31
|
-
"permission_slug" => permission_slug
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
body["
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
body["resource_type_slug"] = resource_target[:resource_type_slug]
|
|
68
|
+
"permission_slug" => permission_slug
|
|
69
|
+
}
|
|
70
|
+
case resource_target
|
|
71
|
+
when WorkOS::Authorization::ResourceTargetById
|
|
72
|
+
body["resource_id"] = resource_target.resource_id
|
|
73
|
+
when WorkOS::Authorization::ResourceTargetByExternalId
|
|
74
|
+
body["resource_external_id"] = resource_target.resource_external_id
|
|
75
|
+
body["resource_type_slug"] = resource_target.resource_type_slug
|
|
76
|
+
else
|
|
77
|
+
raise ArgumentError, "expected resource_target to be one of: WorkOS::Authorization::ResourceTargetById, WorkOS::Authorization::ResourceTargetByExternalId, got #{resource_target.class}"
|
|
42
78
|
end
|
|
43
79
|
response = @client.request(
|
|
44
80
|
method: :post,
|
|
@@ -57,8 +93,9 @@ module WorkOS
|
|
|
57
93
|
# @param before [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `before="obj_123"` to fetch a new batch of objects before `"obj_123"`.
|
|
58
94
|
# @param after [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `after="obj_123"` to fetch a new batch of objects after `"obj_123"`.
|
|
59
95
|
# @param limit [Integer, nil] Upper limit on the number of objects to return, between `1` and `100`.
|
|
60
|
-
# @param order [WorkOS::Types::
|
|
96
|
+
# @param order [WorkOS::Types::PaginationOrder, nil] Order the results by the creation time. Supported values are `"asc"` (ascending), `"desc"` (descending), and `"normal"` (descending with reversed cursor semantics where `before` fetches older records and `after` fetches newer records). Defaults to descending.
|
|
61
97
|
# @param permission_slug [String] The permission slug to filter by. Only child resources where the organization membership has this permission are returned.
|
|
98
|
+
# @param parent_resource [WorkOS::Authorization::ParentResourceById, WorkOS::Authorization::ParentResourceByExternalId] Identifies the parent resource.
|
|
62
99
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
63
100
|
# @return [WorkOS::Types::ListStruct<WorkOS::AuthorizationResource>]
|
|
64
101
|
def list_resources_for_membership(
|
|
@@ -67,7 +104,7 @@ module WorkOS
|
|
|
67
104
|
parent_resource:,
|
|
68
105
|
before: nil,
|
|
69
106
|
after: nil,
|
|
70
|
-
limit:
|
|
107
|
+
limit: 10,
|
|
71
108
|
order: "desc",
|
|
72
109
|
request_options: {}
|
|
73
110
|
)
|
|
@@ -78,12 +115,14 @@ module WorkOS
|
|
|
78
115
|
"order" => order,
|
|
79
116
|
"permission_slug" => permission_slug
|
|
80
117
|
}.compact
|
|
81
|
-
case parent_resource
|
|
82
|
-
when
|
|
83
|
-
params["parent_resource_id"] = parent_resource
|
|
84
|
-
when
|
|
85
|
-
params["parent_resource_type_slug"] = parent_resource
|
|
86
|
-
params["parent_resource_external_id"] = parent_resource
|
|
118
|
+
case parent_resource
|
|
119
|
+
when WorkOS::Authorization::ParentResourceById
|
|
120
|
+
params["parent_resource_id"] = parent_resource.parent_resource_id
|
|
121
|
+
when WorkOS::Authorization::ParentResourceByExternalId
|
|
122
|
+
params["parent_resource_type_slug"] = parent_resource.parent_resource_type_slug
|
|
123
|
+
params["parent_resource_external_id"] = parent_resource.parent_resource_external_id
|
|
124
|
+
else
|
|
125
|
+
raise ArgumentError, "expected parent_resource to be one of: WorkOS::Authorization::ParentResourceById, WorkOS::Authorization::ParentResourceByExternalId, got #{parent_resource.class}"
|
|
87
126
|
end
|
|
88
127
|
response = @client.request(
|
|
89
128
|
method: :get,
|
|
@@ -118,7 +157,7 @@ module WorkOS
|
|
|
118
157
|
# @param before [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `before="obj_123"` to fetch a new batch of objects before `"obj_123"`.
|
|
119
158
|
# @param after [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `after="obj_123"` to fetch a new batch of objects after `"obj_123"`.
|
|
120
159
|
# @param limit [Integer, nil] Upper limit on the number of objects to return, between `1` and `100`.
|
|
121
|
-
# @param order [WorkOS::Types::
|
|
160
|
+
# @param order [WorkOS::Types::PaginationOrder, nil] Order the results by the creation time. Supported values are `"asc"` (ascending), `"desc"` (descending), and `"normal"` (descending with reversed cursor semantics where `before` fetches older records and `after` fetches newer records). Defaults to descending.
|
|
122
161
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
123
162
|
# @return [WorkOS::Types::ListStruct<WorkOS::AuthorizationPermission>]
|
|
124
163
|
def list_effective_permissions(
|
|
@@ -126,7 +165,7 @@ module WorkOS
|
|
|
126
165
|
resource_id:,
|
|
127
166
|
before: nil,
|
|
128
167
|
after: nil,
|
|
129
|
-
limit:
|
|
168
|
+
limit: 10,
|
|
130
169
|
order: "desc",
|
|
131
170
|
request_options: {}
|
|
132
171
|
)
|
|
@@ -169,7 +208,7 @@ module WorkOS
|
|
|
169
208
|
# @param before [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `before="obj_123"` to fetch a new batch of objects before `"obj_123"`.
|
|
170
209
|
# @param after [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `after="obj_123"` to fetch a new batch of objects after `"obj_123"`.
|
|
171
210
|
# @param limit [Integer, nil] Upper limit on the number of objects to return, between `1` and `100`.
|
|
172
|
-
# @param order [WorkOS::Types::
|
|
211
|
+
# @param order [WorkOS::Types::PaginationOrder, nil] Order the results by the creation time. Supported values are `"asc"` (ascending), `"desc"` (descending), and `"normal"` (descending with reversed cursor semantics where `before` fetches older records and `after` fetches newer records). Defaults to descending.
|
|
173
212
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
174
213
|
# @return [WorkOS::Types::ListStruct<WorkOS::AuthorizationPermission>]
|
|
175
214
|
def list_effective_permissions_by_external_id(
|
|
@@ -178,7 +217,7 @@ module WorkOS
|
|
|
178
217
|
external_id:,
|
|
179
218
|
before: nil,
|
|
180
219
|
after: nil,
|
|
181
|
-
limit:
|
|
220
|
+
limit: 10,
|
|
182
221
|
order: "desc",
|
|
183
222
|
request_options: {}
|
|
184
223
|
)
|
|
@@ -220,14 +259,14 @@ module WorkOS
|
|
|
220
259
|
# @param before [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `before="obj_123"` to fetch a new batch of objects before `"obj_123"`.
|
|
221
260
|
# @param after [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `after="obj_123"` to fetch a new batch of objects after `"obj_123"`.
|
|
222
261
|
# @param limit [Integer, nil] Upper limit on the number of objects to return, between `1` and `100`.
|
|
223
|
-
# @param order [WorkOS::Types::
|
|
262
|
+
# @param order [WorkOS::Types::PaginationOrder, nil] Order the results by the creation time. Supported values are `"asc"` (ascending), `"desc"` (descending), and `"normal"` (descending with reversed cursor semantics where `before` fetches older records and `after` fetches newer records). Defaults to descending.
|
|
224
263
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
225
|
-
# @return [WorkOS::Types::ListStruct<WorkOS::
|
|
264
|
+
# @return [WorkOS::Types::ListStruct<WorkOS::UserRoleAssignment>]
|
|
226
265
|
def list_role_assignments(
|
|
227
266
|
organization_membership_id:,
|
|
228
267
|
before: nil,
|
|
229
268
|
after: nil,
|
|
230
|
-
limit:
|
|
269
|
+
limit: 10,
|
|
231
270
|
order: "desc",
|
|
232
271
|
request_options: {}
|
|
233
272
|
)
|
|
@@ -256,7 +295,7 @@ module WorkOS
|
|
|
256
295
|
}
|
|
257
296
|
WorkOS::Types::ListStruct.from_response(
|
|
258
297
|
response,
|
|
259
|
-
model: WorkOS::
|
|
298
|
+
model: WorkOS::UserRoleAssignment,
|
|
260
299
|
filters: {organization_membership_id: organization_membership_id, before: before, limit: limit, order: order},
|
|
261
300
|
fetch_next: fetch_next
|
|
262
301
|
)
|
|
@@ -265,32 +304,26 @@ module WorkOS
|
|
|
265
304
|
# Assign a role
|
|
266
305
|
# @param organization_membership_id [String] The ID of the organization membership.
|
|
267
306
|
# @param role_slug [String] The slug of the role to assign.
|
|
268
|
-
# @param
|
|
269
|
-
# @param resource_external_id [String, nil] The external ID of the resource. Required with `resource_type_slug`. Mutually exclusive with `resource_id`.
|
|
270
|
-
# @param resource_type_slug [String, nil] The resource type slug. Required with `resource_external_id`. Mutually exclusive with `resource_id`.
|
|
307
|
+
# @param resource_target [WorkOS::Authorization::ResourceTargetById, WorkOS::Authorization::ResourceTargetByExternalId] Identifies the resource target.
|
|
271
308
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
272
|
-
# @return [WorkOS::
|
|
309
|
+
# @return [WorkOS::UserRoleAssignment]
|
|
273
310
|
def assign_role(
|
|
274
311
|
organization_membership_id:,
|
|
275
312
|
role_slug:,
|
|
276
313
|
resource_target:,
|
|
277
|
-
resource_id: nil,
|
|
278
|
-
resource_external_id: nil,
|
|
279
|
-
resource_type_slug: nil,
|
|
280
314
|
request_options: {}
|
|
281
315
|
)
|
|
282
316
|
body = {
|
|
283
|
-
"role_slug" => role_slug
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
body["
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
body["resource_type_slug"] = resource_target[:resource_type_slug]
|
|
317
|
+
"role_slug" => role_slug
|
|
318
|
+
}
|
|
319
|
+
case resource_target
|
|
320
|
+
when WorkOS::Authorization::ResourceTargetById
|
|
321
|
+
body["resource_id"] = resource_target.resource_id
|
|
322
|
+
when WorkOS::Authorization::ResourceTargetByExternalId
|
|
323
|
+
body["resource_external_id"] = resource_target.resource_external_id
|
|
324
|
+
body["resource_type_slug"] = resource_target.resource_type_slug
|
|
325
|
+
else
|
|
326
|
+
raise ArgumentError, "expected resource_target to be one of: WorkOS::Authorization::ResourceTargetById, WorkOS::Authorization::ResourceTargetByExternalId, got #{resource_target.class}"
|
|
294
327
|
end
|
|
295
328
|
response = @client.request(
|
|
296
329
|
method: :post,
|
|
@@ -299,7 +332,7 @@ module WorkOS
|
|
|
299
332
|
body: body,
|
|
300
333
|
request_options: request_options
|
|
301
334
|
)
|
|
302
|
-
result = WorkOS::
|
|
335
|
+
result = WorkOS::UserRoleAssignment.new(response.body)
|
|
303
336
|
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"])
|
|
304
337
|
result
|
|
305
338
|
end
|
|
@@ -307,34 +340,28 @@ module WorkOS
|
|
|
307
340
|
# Remove a role assignment
|
|
308
341
|
# @param organization_membership_id [String] The ID of the organization membership.
|
|
309
342
|
# @param role_slug [String] The slug of the role to remove.
|
|
310
|
-
# @param
|
|
311
|
-
# @param resource_external_id [String, nil] The external ID of the resource. Required with `resource_type_slug`. Mutually exclusive with `resource_id`.
|
|
312
|
-
# @param resource_type_slug [String, nil] The resource type slug. Required with `resource_external_id`. Mutually exclusive with `resource_id`.
|
|
343
|
+
# @param resource_target [WorkOS::Authorization::ResourceTargetById, WorkOS::Authorization::ResourceTargetByExternalId] Identifies the resource target.
|
|
313
344
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
314
345
|
# @return [void]
|
|
315
346
|
def remove_role(
|
|
316
347
|
organization_membership_id:,
|
|
317
348
|
role_slug:,
|
|
318
349
|
resource_target:,
|
|
319
|
-
resource_id: nil,
|
|
320
|
-
resource_external_id: nil,
|
|
321
|
-
resource_type_slug: nil,
|
|
322
350
|
request_options: {}
|
|
323
351
|
)
|
|
324
|
-
params = {}
|
|
325
|
-
case resource_target
|
|
326
|
-
when
|
|
327
|
-
params["resource_id"] = resource_target
|
|
328
|
-
when
|
|
329
|
-
params["resource_external_id"] = resource_target
|
|
330
|
-
params["resource_type_slug"] = resource_target
|
|
352
|
+
params = {}
|
|
353
|
+
case resource_target
|
|
354
|
+
when WorkOS::Authorization::ResourceTargetById
|
|
355
|
+
params["resource_id"] = resource_target.resource_id
|
|
356
|
+
when WorkOS::Authorization::ResourceTargetByExternalId
|
|
357
|
+
params["resource_external_id"] = resource_target.resource_external_id
|
|
358
|
+
params["resource_type_slug"] = resource_target.resource_type_slug
|
|
359
|
+
else
|
|
360
|
+
raise ArgumentError, "expected resource_target to be one of: WorkOS::Authorization::ResourceTargetById, WorkOS::Authorization::ResourceTargetByExternalId, got #{resource_target.class}"
|
|
331
361
|
end
|
|
332
362
|
body = {
|
|
333
|
-
"role_slug" => role_slug
|
|
334
|
-
|
|
335
|
-
"resource_external_id" => resource_external_id,
|
|
336
|
-
"resource_type_slug" => resource_type_slug
|
|
337
|
-
}.compact
|
|
363
|
+
"role_slug" => role_slug
|
|
364
|
+
}
|
|
338
365
|
@client.request(
|
|
339
366
|
method: :delete,
|
|
340
367
|
path: "/authorization/organization_memberships/#{WorkOS::Util.encode_path(organization_membership_id)}/role_assignments",
|
|
@@ -502,7 +529,7 @@ module WorkOS
|
|
|
502
529
|
)
|
|
503
530
|
body = {
|
|
504
531
|
"slug" => body_slug
|
|
505
|
-
}
|
|
532
|
+
}
|
|
506
533
|
response = @client.request(
|
|
507
534
|
method: :post,
|
|
508
535
|
path: "/authorization/organizations/#{WorkOS::Util.encode_path(organization_id)}/roles/#{WorkOS::Util.encode_path(slug)}/permissions",
|
|
@@ -529,7 +556,7 @@ module WorkOS
|
|
|
529
556
|
)
|
|
530
557
|
body = {
|
|
531
558
|
"permissions" => permissions
|
|
532
|
-
}
|
|
559
|
+
}
|
|
533
560
|
response = @client.request(
|
|
534
561
|
method: :put,
|
|
535
562
|
path: "/authorization/organizations/#{WorkOS::Util.encode_path(organization_id)}/roles/#{WorkOS::Util.encode_path(slug)}/permissions",
|
|
@@ -594,9 +621,7 @@ module WorkOS
|
|
|
594
621
|
# @param external_id [String] An identifier you provide to reference the resource in your system.
|
|
595
622
|
# @param name [String, nil] A display name for the resource.
|
|
596
623
|
# @param description [String, nil] An optional description of the resource.
|
|
597
|
-
# @param
|
|
598
|
-
# @param parent_resource_external_id [String, nil] The external ID of the parent resource. Required with `parent_resource_type_slug`. Mutually exclusive with `parent_resource_id`.
|
|
599
|
-
# @param parent_resource_type_slug [String, nil] The resource type slug of the parent resource. Required with `parent_resource_external_id`. Mutually exclusive with `parent_resource_id`.
|
|
624
|
+
# @param parent_resource [WorkOS::Authorization::ParentResourceById, WorkOS::Authorization::ParentResourceByExternalId, nil] Identifies the parent resource.
|
|
600
625
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
601
626
|
# @return [WorkOS::AuthorizationResource]
|
|
602
627
|
def update_resource_by_external_id(
|
|
@@ -605,26 +630,22 @@ module WorkOS
|
|
|
605
630
|
external_id:,
|
|
606
631
|
name: nil,
|
|
607
632
|
description: nil,
|
|
608
|
-
parent_resource_id: nil,
|
|
609
|
-
parent_resource_external_id: nil,
|
|
610
|
-
parent_resource_type_slug: nil,
|
|
611
633
|
parent_resource: nil,
|
|
612
634
|
request_options: {}
|
|
613
635
|
)
|
|
614
636
|
body = {
|
|
615
637
|
"name" => name,
|
|
616
|
-
"description" => description
|
|
617
|
-
"parent_resource_id" => parent_resource_id,
|
|
618
|
-
"parent_resource_external_id" => parent_resource_external_id,
|
|
619
|
-
"parent_resource_type_slug" => parent_resource_type_slug
|
|
638
|
+
"description" => description
|
|
620
639
|
}.compact
|
|
621
640
|
if parent_resource
|
|
622
|
-
case parent_resource
|
|
623
|
-
when
|
|
624
|
-
body["parent_resource_id"] = parent_resource
|
|
625
|
-
when
|
|
626
|
-
body["parent_resource_external_id"] = parent_resource
|
|
627
|
-
body["parent_resource_type_slug"] = parent_resource
|
|
641
|
+
case parent_resource
|
|
642
|
+
when WorkOS::Authorization::ParentResourceById
|
|
643
|
+
body["parent_resource_id"] = parent_resource.parent_resource_id
|
|
644
|
+
when WorkOS::Authorization::ParentResourceByExternalId
|
|
645
|
+
body["parent_resource_external_id"] = parent_resource.parent_resource_external_id
|
|
646
|
+
body["parent_resource_type_slug"] = parent_resource.parent_resource_type_slug
|
|
647
|
+
else
|
|
648
|
+
raise ArgumentError, "expected parent_resource to be one of: WorkOS::Authorization::ParentResourceById, WorkOS::Authorization::ParentResourceByExternalId, got #{parent_resource.class}"
|
|
628
649
|
end
|
|
629
650
|
end
|
|
630
651
|
response = @client.request(
|
|
@@ -650,7 +671,7 @@ module WorkOS
|
|
|
650
671
|
organization_id:,
|
|
651
672
|
resource_type_slug:,
|
|
652
673
|
external_id:,
|
|
653
|
-
cascade_delete:
|
|
674
|
+
cascade_delete: false,
|
|
654
675
|
request_options: {}
|
|
655
676
|
)
|
|
656
677
|
params = {
|
|
@@ -673,7 +694,7 @@ module WorkOS
|
|
|
673
694
|
# @param before [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `before="obj_123"` to fetch a new batch of objects before `"obj_123"`.
|
|
674
695
|
# @param after [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `after="obj_123"` to fetch a new batch of objects after `"obj_123"`.
|
|
675
696
|
# @param limit [Integer, nil] Upper limit on the number of objects to return, between `1` and `100`.
|
|
676
|
-
# @param order [WorkOS::Types::
|
|
697
|
+
# @param order [WorkOS::Types::PaginationOrder, nil] Order the results by the creation time. Supported values are `"asc"` (ascending), `"desc"` (descending), and `"normal"` (descending with reversed cursor semantics where `before` fetches older records and `after` fetches newer records). Defaults to descending.
|
|
677
698
|
# @param permission_slug [String] The permission slug to filter by. Only users with this permission on the resource are returned.
|
|
678
699
|
# @param assignment [WorkOS::Types::AuthorizationAssignment, nil] Filter by assignment type. Use "direct" for direct assignments only, or "indirect" to include inherited assignments.
|
|
679
700
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
@@ -685,7 +706,7 @@ module WorkOS
|
|
|
685
706
|
permission_slug:,
|
|
686
707
|
before: nil,
|
|
687
708
|
after: nil,
|
|
688
|
-
limit:
|
|
709
|
+
limit: 10,
|
|
689
710
|
order: "desc",
|
|
690
711
|
assignment: nil,
|
|
691
712
|
request_options: {}
|
|
@@ -727,21 +748,75 @@ module WorkOS
|
|
|
727
748
|
)
|
|
728
749
|
end
|
|
729
750
|
|
|
751
|
+
# List role assignments for a resource by external ID
|
|
752
|
+
# @param organization_id [String] The ID of the organization that owns the resource.
|
|
753
|
+
# @param resource_type_slug [String] The slug of the resource type.
|
|
754
|
+
# @param external_id [String] An identifier you provide to reference the resource in your system.
|
|
755
|
+
# @param before [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `before="obj_123"` to fetch a new batch of objects before `"obj_123"`.
|
|
756
|
+
# @param after [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `after="obj_123"` to fetch a new batch of objects after `"obj_123"`.
|
|
757
|
+
# @param limit [Integer, nil] Upper limit on the number of objects to return, between `1` and `100`.
|
|
758
|
+
# @param order [WorkOS::Types::PaginationOrder, nil] Order the results by the creation time. Supported values are `"asc"` (ascending), `"desc"` (descending), and `"normal"` (descending with reversed cursor semantics where `before` fetches older records and `after` fetches newer records). Defaults to descending.
|
|
759
|
+
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
760
|
+
# @return [WorkOS::Types::ListStruct<WorkOS::UserRoleAssignment>]
|
|
761
|
+
def list_role_assignments_for_resource_by_external_id(
|
|
762
|
+
organization_id:,
|
|
763
|
+
resource_type_slug:,
|
|
764
|
+
external_id:,
|
|
765
|
+
before: nil,
|
|
766
|
+
after: nil,
|
|
767
|
+
limit: 10,
|
|
768
|
+
order: "desc",
|
|
769
|
+
request_options: {}
|
|
770
|
+
)
|
|
771
|
+
params = {
|
|
772
|
+
"before" => before,
|
|
773
|
+
"after" => after,
|
|
774
|
+
"limit" => limit,
|
|
775
|
+
"order" => order
|
|
776
|
+
}.compact
|
|
777
|
+
response = @client.request(
|
|
778
|
+
method: :get,
|
|
779
|
+
path: "/authorization/organizations/#{WorkOS::Util.encode_path(organization_id)}/resources/#{WorkOS::Util.encode_path(resource_type_slug)}/#{WorkOS::Util.encode_path(external_id)}/role_assignments",
|
|
780
|
+
auth: true,
|
|
781
|
+
params: params,
|
|
782
|
+
request_options: request_options
|
|
783
|
+
)
|
|
784
|
+
fetch_next = ->(cursor) {
|
|
785
|
+
list_role_assignments_for_resource_by_external_id(
|
|
786
|
+
organization_id: organization_id,
|
|
787
|
+
resource_type_slug: resource_type_slug,
|
|
788
|
+
external_id: external_id,
|
|
789
|
+
before: before,
|
|
790
|
+
after: cursor,
|
|
791
|
+
limit: limit,
|
|
792
|
+
order: order,
|
|
793
|
+
request_options: request_options
|
|
794
|
+
)
|
|
795
|
+
}
|
|
796
|
+
WorkOS::Types::ListStruct.from_response(
|
|
797
|
+
response,
|
|
798
|
+
model: WorkOS::UserRoleAssignment,
|
|
799
|
+
filters: {organization_id: organization_id, resource_type_slug: resource_type_slug, external_id: external_id, before: before, limit: limit, order: order},
|
|
800
|
+
fetch_next: fetch_next
|
|
801
|
+
)
|
|
802
|
+
end
|
|
803
|
+
|
|
730
804
|
# List resources
|
|
731
805
|
# @param before [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `before="obj_123"` to fetch a new batch of objects before `"obj_123"`.
|
|
732
806
|
# @param after [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `after="obj_123"` to fetch a new batch of objects after `"obj_123"`.
|
|
733
807
|
# @param limit [Integer, nil] Upper limit on the number of objects to return, between `1` and `100`.
|
|
734
|
-
# @param order [WorkOS::Types::
|
|
808
|
+
# @param order [WorkOS::Types::PaginationOrder, nil] Order the results by the creation time. Supported values are `"asc"` (ascending), `"desc"` (descending), and `"normal"` (descending with reversed cursor semantics where `before` fetches older records and `after` fetches newer records). Defaults to descending.
|
|
735
809
|
# @param organization_id [String, nil] Filter resources by organization ID.
|
|
736
810
|
# @param resource_type_slug [String, nil] Filter resources by resource type slug.
|
|
737
811
|
# @param resource_external_id [String, nil] Filter resources by external ID.
|
|
738
812
|
# @param search [String, nil] Search resources by name.
|
|
813
|
+
# @param parent [WorkOS::Authorization::ParentById, WorkOS::Authorization::ParentByExternalId, nil] Identifies the parent.
|
|
739
814
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
740
815
|
# @return [WorkOS::Types::ListStruct<WorkOS::AuthorizationResource>]
|
|
741
816
|
def list_resources(
|
|
742
817
|
before: nil,
|
|
743
818
|
after: nil,
|
|
744
|
-
limit:
|
|
819
|
+
limit: 10,
|
|
745
820
|
order: "desc",
|
|
746
821
|
organization_id: nil,
|
|
747
822
|
resource_type_slug: nil,
|
|
@@ -761,12 +836,14 @@ module WorkOS
|
|
|
761
836
|
"search" => search
|
|
762
837
|
}.compact
|
|
763
838
|
if parent
|
|
764
|
-
case parent
|
|
765
|
-
when
|
|
766
|
-
params["parent_resource_id"] = parent
|
|
767
|
-
when
|
|
768
|
-
params["parent_resource_type_slug"] = parent
|
|
769
|
-
params["parent_external_id"] = parent
|
|
839
|
+
case parent
|
|
840
|
+
when WorkOS::Authorization::ParentById
|
|
841
|
+
params["parent_resource_id"] = parent.parent_resource_id
|
|
842
|
+
when WorkOS::Authorization::ParentByExternalId
|
|
843
|
+
params["parent_resource_type_slug"] = parent.parent_resource_type_slug
|
|
844
|
+
params["parent_external_id"] = parent.parent_external_id
|
|
845
|
+
else
|
|
846
|
+
raise ArgumentError, "expected parent to be one of: WorkOS::Authorization::ParentById, WorkOS::Authorization::ParentByExternalId, got #{parent.class}"
|
|
770
847
|
end
|
|
771
848
|
end
|
|
772
849
|
response = @client.request(
|
|
@@ -804,9 +881,7 @@ module WorkOS
|
|
|
804
881
|
# @param description [String, nil] An optional description of the resource.
|
|
805
882
|
# @param resource_type_slug [String] The slug of the resource type.
|
|
806
883
|
# @param organization_id [String] The ID of the organization this resource belongs to.
|
|
807
|
-
# @param
|
|
808
|
-
# @param parent_resource_external_id [String, nil] The external ID of the parent resource. Required with `parent_resource_type_slug`. Mutually exclusive with `parent_resource_id`.
|
|
809
|
-
# @param parent_resource_type_slug [String, nil] The resource type slug of the parent resource. Required with `parent_resource_external_id`. Mutually exclusive with `parent_resource_id`.
|
|
884
|
+
# @param parent_resource [WorkOS::Authorization::ParentResourceById, WorkOS::Authorization::ParentResourceByExternalId, nil] Identifies the parent resource.
|
|
810
885
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
811
886
|
# @return [WorkOS::AuthorizationResource]
|
|
812
887
|
def create_resource(
|
|
@@ -815,9 +890,6 @@ module WorkOS
|
|
|
815
890
|
resource_type_slug:,
|
|
816
891
|
organization_id:,
|
|
817
892
|
description: nil,
|
|
818
|
-
parent_resource_id: nil,
|
|
819
|
-
parent_resource_external_id: nil,
|
|
820
|
-
parent_resource_type_slug: nil,
|
|
821
893
|
parent_resource: nil,
|
|
822
894
|
request_options: {}
|
|
823
895
|
)
|
|
@@ -826,18 +898,17 @@ module WorkOS
|
|
|
826
898
|
"name" => name,
|
|
827
899
|
"description" => description,
|
|
828
900
|
"resource_type_slug" => resource_type_slug,
|
|
829
|
-
"organization_id" => organization_id
|
|
830
|
-
"parent_resource_id" => parent_resource_id,
|
|
831
|
-
"parent_resource_external_id" => parent_resource_external_id,
|
|
832
|
-
"parent_resource_type_slug" => parent_resource_type_slug
|
|
901
|
+
"organization_id" => organization_id
|
|
833
902
|
}.compact
|
|
834
903
|
if parent_resource
|
|
835
|
-
case parent_resource
|
|
836
|
-
when
|
|
837
|
-
body["parent_resource_id"] = parent_resource
|
|
838
|
-
when
|
|
839
|
-
body["parent_resource_external_id"] = parent_resource
|
|
840
|
-
body["parent_resource_type_slug"] = parent_resource
|
|
904
|
+
case parent_resource
|
|
905
|
+
when WorkOS::Authorization::ParentResourceById
|
|
906
|
+
body["parent_resource_id"] = parent_resource.parent_resource_id
|
|
907
|
+
when WorkOS::Authorization::ParentResourceByExternalId
|
|
908
|
+
body["parent_resource_external_id"] = parent_resource.parent_resource_external_id
|
|
909
|
+
body["parent_resource_type_slug"] = parent_resource.parent_resource_type_slug
|
|
910
|
+
else
|
|
911
|
+
raise ArgumentError, "expected parent_resource to be one of: WorkOS::Authorization::ParentResourceById, WorkOS::Authorization::ParentResourceByExternalId, got #{parent_resource.class}"
|
|
841
912
|
end
|
|
842
913
|
end
|
|
843
914
|
response = @client.request(
|
|
@@ -875,35 +946,29 @@ module WorkOS
|
|
|
875
946
|
# @param resource_id [String] The ID of the authorization resource.
|
|
876
947
|
# @param name [String, nil] A display name for the resource.
|
|
877
948
|
# @param description [String, nil] An optional description of the resource.
|
|
878
|
-
# @param
|
|
879
|
-
# @param parent_resource_external_id [String, nil] The external ID of the parent resource. Required with `parent_resource_type_slug`. Mutually exclusive with `parent_resource_id`.
|
|
880
|
-
# @param parent_resource_type_slug [String, nil] The resource type slug of the parent resource. Required with `parent_resource_external_id`. Mutually exclusive with `parent_resource_id`.
|
|
949
|
+
# @param parent_resource [WorkOS::Authorization::ParentResourceById, WorkOS::Authorization::ParentResourceByExternalId, nil] Identifies the parent resource.
|
|
881
950
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
882
951
|
# @return [WorkOS::AuthorizationResource]
|
|
883
952
|
def update_resource(
|
|
884
953
|
resource_id:,
|
|
885
954
|
name: nil,
|
|
886
955
|
description: nil,
|
|
887
|
-
parent_resource_id: nil,
|
|
888
|
-
parent_resource_external_id: nil,
|
|
889
|
-
parent_resource_type_slug: nil,
|
|
890
956
|
parent_resource: nil,
|
|
891
957
|
request_options: {}
|
|
892
958
|
)
|
|
893
959
|
body = {
|
|
894
960
|
"name" => name,
|
|
895
|
-
"description" => description
|
|
896
|
-
"parent_resource_id" => parent_resource_id,
|
|
897
|
-
"parent_resource_external_id" => parent_resource_external_id,
|
|
898
|
-
"parent_resource_type_slug" => parent_resource_type_slug
|
|
961
|
+
"description" => description
|
|
899
962
|
}.compact
|
|
900
963
|
if parent_resource
|
|
901
|
-
case parent_resource
|
|
902
|
-
when
|
|
903
|
-
body["parent_resource_id"] = parent_resource
|
|
904
|
-
when
|
|
905
|
-
body["parent_resource_external_id"] = parent_resource
|
|
906
|
-
body["parent_resource_type_slug"] = parent_resource
|
|
964
|
+
case parent_resource
|
|
965
|
+
when WorkOS::Authorization::ParentResourceById
|
|
966
|
+
body["parent_resource_id"] = parent_resource.parent_resource_id
|
|
967
|
+
when WorkOS::Authorization::ParentResourceByExternalId
|
|
968
|
+
body["parent_resource_external_id"] = parent_resource.parent_resource_external_id
|
|
969
|
+
body["parent_resource_type_slug"] = parent_resource.parent_resource_type_slug
|
|
970
|
+
else
|
|
971
|
+
raise ArgumentError, "expected parent_resource to be one of: WorkOS::Authorization::ParentResourceById, WorkOS::Authorization::ParentResourceByExternalId, got #{parent_resource.class}"
|
|
907
972
|
end
|
|
908
973
|
end
|
|
909
974
|
response = @client.request(
|
|
@@ -925,7 +990,7 @@ module WorkOS
|
|
|
925
990
|
# @return [void]
|
|
926
991
|
def delete_resource(
|
|
927
992
|
resource_id:,
|
|
928
|
-
cascade_delete:
|
|
993
|
+
cascade_delete: false,
|
|
929
994
|
request_options: {}
|
|
930
995
|
)
|
|
931
996
|
params = {
|
|
@@ -946,7 +1011,7 @@ module WorkOS
|
|
|
946
1011
|
# @param before [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `before="obj_123"` to fetch a new batch of objects before `"obj_123"`.
|
|
947
1012
|
# @param after [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `after="obj_123"` to fetch a new batch of objects after `"obj_123"`.
|
|
948
1013
|
# @param limit [Integer, nil] Upper limit on the number of objects to return, between `1` and `100`.
|
|
949
|
-
# @param order [WorkOS::Types::
|
|
1014
|
+
# @param order [WorkOS::Types::PaginationOrder, nil] Order the results by the creation time. Supported values are `"asc"` (ascending), `"desc"` (descending), and `"normal"` (descending with reversed cursor semantics where `before` fetches older records and `after` fetches newer records). Defaults to descending.
|
|
950
1015
|
# @param permission_slug [String] The permission slug to filter by. Only users with this permission on the resource are returned.
|
|
951
1016
|
# @param assignment [WorkOS::Types::AuthorizationAssignment, nil] Filter by assignment type. Use `direct` for direct assignments only, or `indirect` to include inherited assignments.
|
|
952
1017
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
@@ -956,7 +1021,7 @@ module WorkOS
|
|
|
956
1021
|
permission_slug:,
|
|
957
1022
|
before: nil,
|
|
958
1023
|
after: nil,
|
|
959
|
-
limit:
|
|
1024
|
+
limit: 10,
|
|
960
1025
|
order: "desc",
|
|
961
1026
|
assignment: nil,
|
|
962
1027
|
request_options: {}
|
|
@@ -996,6 +1061,53 @@ module WorkOS
|
|
|
996
1061
|
)
|
|
997
1062
|
end
|
|
998
1063
|
|
|
1064
|
+
# List role assignments for a resource
|
|
1065
|
+
# @param resource_id [String] The ID of the authorization resource.
|
|
1066
|
+
# @param before [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `before="obj_123"` to fetch a new batch of objects before `"obj_123"`.
|
|
1067
|
+
# @param after [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `after="obj_123"` to fetch a new batch of objects after `"obj_123"`.
|
|
1068
|
+
# @param limit [Integer, nil] Upper limit on the number of objects to return, between `1` and `100`.
|
|
1069
|
+
# @param order [WorkOS::Types::PaginationOrder, nil] Order the results by the creation time. Supported values are `"asc"` (ascending), `"desc"` (descending), and `"normal"` (descending with reversed cursor semantics where `before` fetches older records and `after` fetches newer records). Defaults to descending.
|
|
1070
|
+
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
1071
|
+
# @return [WorkOS::Types::ListStruct<WorkOS::UserRoleAssignment>]
|
|
1072
|
+
def list_role_assignments_for_resource(
|
|
1073
|
+
resource_id:,
|
|
1074
|
+
before: nil,
|
|
1075
|
+
after: nil,
|
|
1076
|
+
limit: 10,
|
|
1077
|
+
order: "desc",
|
|
1078
|
+
request_options: {}
|
|
1079
|
+
)
|
|
1080
|
+
params = {
|
|
1081
|
+
"before" => before,
|
|
1082
|
+
"after" => after,
|
|
1083
|
+
"limit" => limit,
|
|
1084
|
+
"order" => order
|
|
1085
|
+
}.compact
|
|
1086
|
+
response = @client.request(
|
|
1087
|
+
method: :get,
|
|
1088
|
+
path: "/authorization/resources/#{WorkOS::Util.encode_path(resource_id)}/role_assignments",
|
|
1089
|
+
auth: true,
|
|
1090
|
+
params: params,
|
|
1091
|
+
request_options: request_options
|
|
1092
|
+
)
|
|
1093
|
+
fetch_next = ->(cursor) {
|
|
1094
|
+
list_role_assignments_for_resource(
|
|
1095
|
+
resource_id: resource_id,
|
|
1096
|
+
before: before,
|
|
1097
|
+
after: cursor,
|
|
1098
|
+
limit: limit,
|
|
1099
|
+
order: order,
|
|
1100
|
+
request_options: request_options
|
|
1101
|
+
)
|
|
1102
|
+
}
|
|
1103
|
+
WorkOS::Types::ListStruct.from_response(
|
|
1104
|
+
response,
|
|
1105
|
+
model: WorkOS::UserRoleAssignment,
|
|
1106
|
+
filters: {resource_id: resource_id, before: before, limit: limit, order: order},
|
|
1107
|
+
fetch_next: fetch_next
|
|
1108
|
+
)
|
|
1109
|
+
end
|
|
1110
|
+
|
|
999
1111
|
# List environment roles
|
|
1000
1112
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
1001
1113
|
# @return [WorkOS::RoleList]
|
|
@@ -1102,7 +1214,7 @@ module WorkOS
|
|
|
1102
1214
|
)
|
|
1103
1215
|
body = {
|
|
1104
1216
|
"slug" => body_slug
|
|
1105
|
-
}
|
|
1217
|
+
}
|
|
1106
1218
|
response = @client.request(
|
|
1107
1219
|
method: :post,
|
|
1108
1220
|
path: "/authorization/roles/#{WorkOS::Util.encode_path(slug)}/permissions",
|
|
@@ -1127,7 +1239,7 @@ module WorkOS
|
|
|
1127
1239
|
)
|
|
1128
1240
|
body = {
|
|
1129
1241
|
"permissions" => permissions
|
|
1130
|
-
}
|
|
1242
|
+
}
|
|
1131
1243
|
response = @client.request(
|
|
1132
1244
|
method: :put,
|
|
1133
1245
|
path: "/authorization/roles/#{WorkOS::Util.encode_path(slug)}/permissions",
|
|
@@ -1144,13 +1256,13 @@ module WorkOS
|
|
|
1144
1256
|
# @param before [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `before="obj_123"` to fetch a new batch of objects before `"obj_123"`.
|
|
1145
1257
|
# @param after [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `after="obj_123"` to fetch a new batch of objects after `"obj_123"`.
|
|
1146
1258
|
# @param limit [Integer, nil] Upper limit on the number of objects to return, between `1` and `100`.
|
|
1147
|
-
# @param order [WorkOS::Types::
|
|
1259
|
+
# @param order [WorkOS::Types::PaginationOrder, nil] Order the results by the creation time. Supported values are `"asc"` (ascending), `"desc"` (descending), and `"normal"` (descending with reversed cursor semantics where `before` fetches older records and `after` fetches newer records). Defaults to descending.
|
|
1148
1260
|
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
|
|
1149
1261
|
# @return [WorkOS::Types::ListStruct<WorkOS::AuthorizationPermission>]
|
|
1150
1262
|
def list_permissions(
|
|
1151
1263
|
before: nil,
|
|
1152
1264
|
after: nil,
|
|
1153
|
-
limit:
|
|
1265
|
+
limit: 10,
|
|
1154
1266
|
order: "desc",
|
|
1155
1267
|
request_options: {}
|
|
1156
1268
|
)
|