Skip to content

Commit 78c8812

Browse files
authored
feat(iam): add SCIM related endpoints (#1367)
1 parent 15ec87e commit 78c8812

File tree

8 files changed

+856
-0
lines changed

8 files changed

+856
-0
lines changed

scaleway-async/scaleway_async/iam/v1alpha1/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from .types import ListPoliciesRequestOrderBy
1212
from .types import ListQuotaRequestOrderBy
1313
from .types import ListSSHKeysRequestOrderBy
14+
from .types import ListScimTokensRequestOrderBy
1415
from .types import ListUsersRequestOrderBy
1516
from .types import LocalityType
1617
from .types import LogAction
@@ -26,6 +27,7 @@
2627
from .types import QuotumLimit
2728
from .types import JWT
2829
from .types import RuleSpecs
30+
from .types import ScimToken
2931
from .types import CreateUserRequestMember
3032
from .types import Connection
3133
from .types import APIKey
@@ -51,6 +53,8 @@
5153
from .types import CreateJWTRequest
5254
from .types import CreatePolicyRequest
5355
from .types import CreateSSHKeyRequest
56+
from .types import CreateScimTokenRequest
57+
from .types import CreateScimTokenResponse
5458
from .types import CreateUserMFAOTPRequest
5559
from .types import CreateUserRequest
5660
from .types import DeleteAPIKeyRequest
@@ -61,9 +65,12 @@
6165
from .types import DeleteSSHKeyRequest
6266
from .types import DeleteSamlCertificateRequest
6367
from .types import DeleteSamlRequest
68+
from .types import DeleteScimRequest
69+
from .types import DeleteScimTokenRequest
6470
from .types import DeleteUserMFAOTPRequest
6571
from .types import DeleteUserRequest
6672
from .types import EnableOrganizationSamlRequest
73+
from .types import EnableOrganizationScimRequest
6774
from .types import EncodedJWT
6875
from .types import GetAPIKeyRequest
6976
from .types import GetApplicationRequest
@@ -106,6 +113,8 @@
106113
from .types import ListSSHKeysResponse
107114
from .types import ListSamlCertificatesRequest
108115
from .types import ListSamlCertificatesResponse
116+
from .types import ListScimTokensRequest
117+
from .types import ListScimTokensResponse
109118
from .types import ListUsersRequest
110119
from .types import ListUsersResponse
111120
from .types import LockUserRequest
@@ -117,6 +126,7 @@
117126
from .types import RemoveGroupMemberRequest
118127
from .types import RemoveUserConnectionRequest
119128
from .types import Saml
129+
from .types import Scim
120130
from .types import SetGroupMembersRequest
121131
from .types import SetOrganizationAliasRequest
122132
from .types import SetRulesRequest
@@ -149,6 +159,7 @@
149159
"ListPoliciesRequestOrderBy",
150160
"ListQuotaRequestOrderBy",
151161
"ListSSHKeysRequestOrderBy",
162+
"ListScimTokensRequestOrderBy",
152163
"ListUsersRequestOrderBy",
153164
"LocalityType",
154165
"LogAction",
@@ -164,6 +175,7 @@
164175
"QuotumLimit",
165176
"JWT",
166177
"RuleSpecs",
178+
"ScimToken",
167179
"CreateUserRequestMember",
168180
"Connection",
169181
"APIKey",
@@ -189,6 +201,8 @@
189201
"CreateJWTRequest",
190202
"CreatePolicyRequest",
191203
"CreateSSHKeyRequest",
204+
"CreateScimTokenRequest",
205+
"CreateScimTokenResponse",
192206
"CreateUserMFAOTPRequest",
193207
"CreateUserRequest",
194208
"DeleteAPIKeyRequest",
@@ -199,9 +213,12 @@
199213
"DeleteSSHKeyRequest",
200214
"DeleteSamlCertificateRequest",
201215
"DeleteSamlRequest",
216+
"DeleteScimRequest",
217+
"DeleteScimTokenRequest",
202218
"DeleteUserMFAOTPRequest",
203219
"DeleteUserRequest",
204220
"EnableOrganizationSamlRequest",
221+
"EnableOrganizationScimRequest",
205222
"EncodedJWT",
206223
"GetAPIKeyRequest",
207224
"GetApplicationRequest",
@@ -244,6 +261,8 @@
244261
"ListSSHKeysResponse",
245262
"ListSamlCertificatesRequest",
246263
"ListSamlCertificatesResponse",
264+
"ListScimTokensRequest",
265+
"ListScimTokensResponse",
247266
"ListUsersRequest",
248267
"ListUsersResponse",
249268
"LockUserRequest",
@@ -255,6 +274,7 @@
255274
"RemoveGroupMemberRequest",
256275
"RemoveUserConnectionRequest",
257276
"Saml",
277+
"Scim",
258278
"SetGroupMembersRequest",
259279
"SetOrganizationAliasRequest",
260280
"SetRulesRequest",

scaleway-async/scaleway_async/iam/v1alpha1/api.py

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
ListPoliciesRequestOrderBy,
2727
ListQuotaRequestOrderBy,
2828
ListSSHKeysRequestOrderBy,
29+
ListScimTokensRequestOrderBy,
2930
ListUsersRequestOrderBy,
3031
LogAction,
3132
LogResourceType,
@@ -42,6 +43,7 @@
4243
CreateJWTRequest,
4344
CreatePolicyRequest,
4445
CreateSSHKeyRequest,
46+
CreateScimTokenResponse,
4547
CreateUserRequest,
4648
CreateUserRequestMember,
4749
EncodedJWT,
@@ -62,6 +64,7 @@
6264
ListRulesResponse,
6365
ListSSHKeysResponse,
6466
ListSamlCertificatesResponse,
67+
ListScimTokensResponse,
6568
ListUsersResponse,
6669
Log,
6770
MFAOTP,
@@ -79,6 +82,8 @@
7982
SSHKey,
8083
Saml,
8184
SamlCertificate,
85+
Scim,
86+
ScimToken,
8287
SetGroupMembersRequest,
8388
SetOrganizationAliasRequest,
8489
SetRulesRequest,
@@ -109,6 +114,7 @@
109114
unmarshal_SSHKey,
110115
unmarshal_SamlCertificate,
111116
unmarshal_User,
117+
unmarshal_CreateScimTokenResponse,
112118
unmarshal_EncodedJWT,
113119
unmarshal_GetUserConnectionsResponse,
114120
unmarshal_InitiateUserConnectionResponse,
@@ -124,12 +130,14 @@
124130
unmarshal_ListRulesResponse,
125131
unmarshal_ListSSHKeysResponse,
126132
unmarshal_ListSamlCertificatesResponse,
133+
unmarshal_ListScimTokensResponse,
127134
unmarshal_ListUsersResponse,
128135
unmarshal_MFAOTP,
129136
unmarshal_Organization,
130137
unmarshal_OrganizationSecuritySettings,
131138
unmarshal_ParseSamlMetadataResponse,
132139
unmarshal_Saml,
140+
unmarshal_Scim,
133141
unmarshal_SetRulesResponse,
134142
unmarshal_ValidateUserMFAOTPResponse,
135143
marshal_AddGroupMemberRequest,
@@ -3328,3 +3336,181 @@ async def delete_saml_certificate(
33283336
)
33293337

33303338
self._throw_on_error(res)
3339+
3340+
async def enable_organization_scim(
3341+
self,
3342+
*,
3343+
organization_id: Optional[str] = None,
3344+
) -> Scim:
3345+
"""
3346+
:param organization_id: ID of the Organization.
3347+
:return: :class:`Scim <Scim>`
3348+
3349+
Usage:
3350+
::
3351+
3352+
result = await api.enable_organization_scim()
3353+
"""
3354+
3355+
param_organization_id = validate_path_param(
3356+
"organization_id", organization_id or self.client.default_organization_id
3357+
)
3358+
3359+
res = self._request(
3360+
"POST",
3361+
f"/iam/v1alpha1/organizations/{param_organization_id}/scim",
3362+
body={},
3363+
)
3364+
3365+
self._throw_on_error(res)
3366+
return unmarshal_Scim(res.json())
3367+
3368+
async def delete_scim(
3369+
self,
3370+
*,
3371+
scim_id: str,
3372+
) -> None:
3373+
"""
3374+
:param scim_id: ID of the SCIM configuration.
3375+
3376+
Usage:
3377+
::
3378+
3379+
result = await api.delete_scim(
3380+
scim_id="example",
3381+
)
3382+
"""
3383+
3384+
param_scim_id = validate_path_param("scim_id", scim_id)
3385+
3386+
res = self._request(
3387+
"DELETE",
3388+
f"/iam/v1alpha1/scim/{param_scim_id}",
3389+
)
3390+
3391+
self._throw_on_error(res)
3392+
3393+
async def list_scim_tokens(
3394+
self,
3395+
*,
3396+
scim_id: str,
3397+
order_by: Optional[ListScimTokensRequestOrderBy] = None,
3398+
page: Optional[int] = None,
3399+
page_size: Optional[int] = None,
3400+
) -> ListScimTokensResponse:
3401+
"""
3402+
:param scim_id: ID of the SCIM configuration.
3403+
:param order_by: Sort order of SCIM tokens.
3404+
:param page: Requested page number. Value must be greater or equal to 1.
3405+
:param page_size: Number of items per page. Value must be between 1 and 100.
3406+
:return: :class:`ListScimTokensResponse <ListScimTokensResponse>`
3407+
3408+
Usage:
3409+
::
3410+
3411+
result = await api.list_scim_tokens(
3412+
scim_id="example",
3413+
)
3414+
"""
3415+
3416+
param_scim_id = validate_path_param("scim_id", scim_id)
3417+
3418+
res = self._request(
3419+
"GET",
3420+
f"/iam/v1alpha1/scim/{param_scim_id}/tokens",
3421+
params={
3422+
"order_by": order_by,
3423+
"page": page,
3424+
"page_size": page_size or self.client.default_page_size,
3425+
},
3426+
)
3427+
3428+
self._throw_on_error(res)
3429+
return unmarshal_ListScimTokensResponse(res.json())
3430+
3431+
async def list_scim_tokens_all(
3432+
self,
3433+
*,
3434+
scim_id: str,
3435+
order_by: Optional[ListScimTokensRequestOrderBy] = None,
3436+
page: Optional[int] = None,
3437+
page_size: Optional[int] = None,
3438+
) -> list[ScimToken]:
3439+
"""
3440+
:param scim_id: ID of the SCIM configuration.
3441+
:param order_by: Sort order of SCIM tokens.
3442+
:param page: Requested page number. Value must be greater or equal to 1.
3443+
:param page_size: Number of items per page. Value must be between 1 and 100.
3444+
:return: :class:`list[ScimToken] <list[ScimToken]>`
3445+
3446+
Usage:
3447+
::
3448+
3449+
result = await api.list_scim_tokens_all(
3450+
scim_id="example",
3451+
)
3452+
"""
3453+
3454+
return await fetch_all_pages_async(
3455+
type=ListScimTokensResponse,
3456+
key="scim_tokens",
3457+
fetcher=self.list_scim_tokens,
3458+
args={
3459+
"scim_id": scim_id,
3460+
"order_by": order_by,
3461+
"page": page,
3462+
"page_size": page_size,
3463+
},
3464+
)
3465+
3466+
async def create_scim_token(
3467+
self,
3468+
*,
3469+
scim_id: str,
3470+
) -> CreateScimTokenResponse:
3471+
"""
3472+
:param scim_id: ID of the SCIM configuration.
3473+
:return: :class:`CreateScimTokenResponse <CreateScimTokenResponse>`
3474+
3475+
Usage:
3476+
::
3477+
3478+
result = await api.create_scim_token(
3479+
scim_id="example",
3480+
)
3481+
"""
3482+
3483+
param_scim_id = validate_path_param("scim_id", scim_id)
3484+
3485+
res = self._request(
3486+
"POST",
3487+
f"/iam/v1alpha1/scim/{param_scim_id}/tokens",
3488+
)
3489+
3490+
self._throw_on_error(res)
3491+
return unmarshal_CreateScimTokenResponse(res.json())
3492+
3493+
async def delete_scim_token(
3494+
self,
3495+
*,
3496+
token_id: str,
3497+
) -> None:
3498+
"""
3499+
:param token_id: The SCIM token ID.
3500+
3501+
Usage:
3502+
::
3503+
3504+
result = await api.delete_scim_token(
3505+
token_id="example",
3506+
)
3507+
"""
3508+
3509+
param_token_id = validate_path_param("token_id", token_id)
3510+
3511+
res = self._request(
3512+
"DELETE",
3513+
f"/iam/v1alpha1/scim-tokens/{param_token_id}",
3514+
)
3515+
3516+
self._throw_on_error(res)

0 commit comments

Comments
 (0)