From 23864995346d93ee96274fb6e943f0246bcd483e Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Thu, 10 Jul 2025 15:36:04 +0000 Subject: [PATCH] feat: update generated APIs --- .../scaleway_async/iam/v1alpha1/__init__.py | 24 ++ .../scaleway_async/iam/v1alpha1/api.py | 246 ++++++++++++++++++ .../iam/v1alpha1/marshalling.py | 124 +++++++++ .../scaleway_async/iam/v1alpha1/types.py | 158 +++++++++++ scaleway/scaleway/iam/v1alpha1/__init__.py | 24 ++ scaleway/scaleway/iam/v1alpha1/api.py | 246 ++++++++++++++++++ scaleway/scaleway/iam/v1alpha1/marshalling.py | 124 +++++++++ scaleway/scaleway/iam/v1alpha1/types.py | 158 +++++++++++ 8 files changed, 1104 insertions(+) diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py b/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py index 089264bd2..ae8c64ef7 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py @@ -16,6 +16,8 @@ from .types import LogAction from .types import LogResourceType from .types import PermissionSetScopeType +from .types import SamlCertificateOrigin +from .types import SamlCertificateType from .types import UserStatus from .types import UserType from .types import ConnectionConnectedOrganization @@ -35,14 +37,17 @@ from .types import Quotum from .types import Rule from .types import SSHKey +from .types import SamlCertificate from .types import User from .types import AddGroupMemberRequest from .types import AddGroupMembersRequest +from .types import AddSamlCertificateRequest from .types import ClonePolicyRequest from .types import CreateAPIKeyRequest from .types import CreateApplicationRequest from .types import CreateGroupRequest from .types import CreateJWTRequest +from .types import CreateOrganizationSamlRequest from .types import CreatePolicyRequest from .types import CreateSSHKeyRequest from .types import CreateUserMFAOTPRequest @@ -51,8 +56,10 @@ from .types import DeleteApplicationRequest from .types import DeleteGroupRequest from .types import DeleteJWTRequest +from .types import DeleteOrganizationSamlRequest from .types import DeletePolicyRequest from .types import DeleteSSHKeyRequest +from .types import DeleteSamlCertificateRequest from .types import DeleteUserMFAOTPRequest from .types import DeleteUserRequest from .types import EncodedJWT @@ -62,6 +69,7 @@ from .types import GetJWTRequest from .types import GetLogRequest from .types import GetOrganizationRequest +from .types import GetOrganizationSamlRequest from .types import GetOrganizationSecuritySettingsRequest from .types import GetPolicyRequest from .types import GetQuotumRequest @@ -94,6 +102,8 @@ from .types import ListRulesResponse from .types import ListSSHKeysRequest from .types import ListSSHKeysResponse +from .types import ListSamlCertificatesRequest +from .types import ListSamlCertificatesResponse from .types import ListUsersRequest from .types import ListUsersResponse from .types import LockUserRequest @@ -103,6 +113,7 @@ from .types import OrganizationSecuritySettings from .types import RemoveGroupMemberRequest from .types import RemoveUserConnectionRequest +from .types import Saml from .types import SetGroupMembersRequest from .types import SetOrganizationAliasRequest from .types import SetRulesRequest @@ -111,6 +122,7 @@ from .types import UpdateAPIKeyRequest from .types import UpdateApplicationRequest from .types import UpdateGroupRequest +from .types import UpdateOrganizationSamlRequest from .types import UpdateOrganizationSecuritySettingsRequest from .types import UpdatePolicyRequest from .types import UpdateSSHKeyRequest @@ -138,6 +150,8 @@ "LogAction", "LogResourceType", "PermissionSetScopeType", + "SamlCertificateOrigin", + "SamlCertificateType", "UserStatus", "UserType", "ConnectionConnectedOrganization", @@ -157,14 +171,17 @@ "Quotum", "Rule", "SSHKey", + "SamlCertificate", "User", "AddGroupMemberRequest", "AddGroupMembersRequest", + "AddSamlCertificateRequest", "ClonePolicyRequest", "CreateAPIKeyRequest", "CreateApplicationRequest", "CreateGroupRequest", "CreateJWTRequest", + "CreateOrganizationSamlRequest", "CreatePolicyRequest", "CreateSSHKeyRequest", "CreateUserMFAOTPRequest", @@ -173,8 +190,10 @@ "DeleteApplicationRequest", "DeleteGroupRequest", "DeleteJWTRequest", + "DeleteOrganizationSamlRequest", "DeletePolicyRequest", "DeleteSSHKeyRequest", + "DeleteSamlCertificateRequest", "DeleteUserMFAOTPRequest", "DeleteUserRequest", "EncodedJWT", @@ -184,6 +203,7 @@ "GetJWTRequest", "GetLogRequest", "GetOrganizationRequest", + "GetOrganizationSamlRequest", "GetOrganizationSecuritySettingsRequest", "GetPolicyRequest", "GetQuotumRequest", @@ -216,6 +236,8 @@ "ListRulesResponse", "ListSSHKeysRequest", "ListSSHKeysResponse", + "ListSamlCertificatesRequest", + "ListSamlCertificatesResponse", "ListUsersRequest", "ListUsersResponse", "LockUserRequest", @@ -225,6 +247,7 @@ "OrganizationSecuritySettings", "RemoveGroupMemberRequest", "RemoveUserConnectionRequest", + "Saml", "SetGroupMembersRequest", "SetOrganizationAliasRequest", "SetRulesRequest", @@ -233,6 +256,7 @@ "UpdateAPIKeyRequest", "UpdateApplicationRequest", "UpdateGroupRequest", + "UpdateOrganizationSamlRequest", "UpdateOrganizationSecuritySettingsRequest", "UpdatePolicyRequest", "UpdateSSHKeyRequest", diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/api.py b/scaleway-async/scaleway_async/iam/v1alpha1/api.py index b450d5bde..567b84f7a 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/api.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/api.py @@ -26,15 +26,18 @@ ListUsersRequestOrderBy, LogAction, LogResourceType, + SamlCertificateType, UserType, APIKey, AddGroupMemberRequest, AddGroupMembersRequest, + AddSamlCertificateRequest, Application, CreateAPIKeyRequest, CreateApplicationRequest, CreateGroupRequest, CreateJWTRequest, + CreateOrganizationSamlRequest, CreatePolicyRequest, CreateSSHKeyRequest, CreateUserRequest, @@ -56,6 +59,7 @@ ListQuotaResponse, ListRulesResponse, ListSSHKeysResponse, + ListSamlCertificatesResponse, ListUsersResponse, Log, MFAOTP, @@ -69,6 +73,8 @@ Rule, RuleSpecs, SSHKey, + Saml, + SamlCertificate, SetGroupMembersRequest, SetOrganizationAliasRequest, SetRulesRequest, @@ -76,6 +82,7 @@ UpdateAPIKeyRequest, UpdateApplicationRequest, UpdateGroupRequest, + UpdateOrganizationSamlRequest, UpdateOrganizationSecuritySettingsRequest, UpdatePolicyRequest, UpdateSSHKeyRequest, @@ -95,6 +102,7 @@ unmarshal_Policy, unmarshal_Quotum, unmarshal_SSHKey, + unmarshal_SamlCertificate, unmarshal_User, unmarshal_EncodedJWT, unmarshal_GetUserConnectionsResponse, @@ -110,18 +118,22 @@ unmarshal_ListQuotaResponse, unmarshal_ListRulesResponse, unmarshal_ListSSHKeysResponse, + unmarshal_ListSamlCertificatesResponse, unmarshal_ListUsersResponse, unmarshal_MFAOTP, unmarshal_Organization, unmarshal_OrganizationSecuritySettings, + unmarshal_Saml, unmarshal_SetRulesResponse, unmarshal_ValidateUserMFAOTPResponse, marshal_AddGroupMemberRequest, marshal_AddGroupMembersRequest, + marshal_AddSamlCertificateRequest, marshal_CreateAPIKeyRequest, marshal_CreateApplicationRequest, marshal_CreateGroupRequest, marshal_CreateJWTRequest, + marshal_CreateOrganizationSamlRequest, marshal_CreatePolicyRequest, marshal_CreateSSHKeyRequest, marshal_CreateUserRequest, @@ -134,6 +146,7 @@ marshal_UpdateAPIKeyRequest, marshal_UpdateApplicationRequest, marshal_UpdateGroupRequest, + marshal_UpdateOrganizationSamlRequest, marshal_UpdateOrganizationSecuritySettingsRequest, marshal_UpdatePolicyRequest, marshal_UpdateSSHKeyRequest, @@ -3028,3 +3041,236 @@ async def migrate_organization_guests( ) self._throw_on_error(res) + + async def get_organization_saml( + self, + *, + organization_id: Optional[str] = None, + ) -> Saml: + """ + Get SAML Identity Provider configuration of an Organization. + :param organization_id: ID of the Organization. + :return: :class:`Saml ` + + Usage: + :: + + result = await api.get_organization_saml() + """ + + param_organization_id = validate_path_param( + "organization_id", organization_id or self.client.default_organization_id + ) + + res = self._request( + "GET", + f"/iam/v1alpha1/organizations/{param_organization_id}/saml", + ) + + self._throw_on_error(res) + return unmarshal_Saml(res.json()) + + async def create_organization_saml( + self, + *, + entity_id: str, + single_sign_on_url: str, + organization_id: Optional[str] = None, + ) -> Saml: + """ + Create a SAML Identity Provider configuration for an Organization. + :param entity_id: Entity ID of the SAML Identity Provider. + :param single_sign_on_url: Single Sign-On URL of the SAML Identity Provider. + :param organization_id: ID of the Organization. + :return: :class:`Saml ` + + Usage: + :: + + result = await api.create_organization_saml( + entity_id="example", + single_sign_on_url="example", + ) + """ + + param_organization_id = validate_path_param( + "organization_id", organization_id or self.client.default_organization_id + ) + + res = self._request( + "POST", + f"/iam/v1alpha1/organizations/{param_organization_id}/saml", + body=marshal_CreateOrganizationSamlRequest( + CreateOrganizationSamlRequest( + entity_id=entity_id, + single_sign_on_url=single_sign_on_url, + organization_id=organization_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Saml(res.json()) + + async def update_organization_saml( + self, + *, + organization_id: Optional[str] = None, + entity_id: Optional[str] = None, + single_sign_on_url: Optional[str] = None, + ) -> Saml: + """ + Update a SAML Identity Provider configuration for an Organization. + :param organization_id: ID of the Organization. + :param entity_id: Entity ID of the SAML Identity Provider. + :param single_sign_on_url: Single Sign-On URL of the SAML Identity Provider. + :return: :class:`Saml ` + + Usage: + :: + + result = await api.update_organization_saml() + """ + + param_organization_id = validate_path_param( + "organization_id", organization_id or self.client.default_organization_id + ) + + res = self._request( + "PATCH", + f"/iam/v1alpha1/organizations/{param_organization_id}/saml", + body=marshal_UpdateOrganizationSamlRequest( + UpdateOrganizationSamlRequest( + organization_id=organization_id, + entity_id=entity_id, + single_sign_on_url=single_sign_on_url, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Saml(res.json()) + + async def delete_organization_saml( + self, + *, + organization_id: Optional[str] = None, + ) -> None: + """ + Delete a SAML Identity Provider configuration for an Organization. + :param organization_id: ID of the Organization. + + Usage: + :: + + result = await api.delete_organization_saml() + """ + + param_organization_id = validate_path_param( + "organization_id", organization_id or self.client.default_organization_id + ) + + res = self._request( + "DELETE", + f"/iam/v1alpha1/organizations/{param_organization_id}/saml", + ) + + self._throw_on_error(res) + + async def list_saml_certificates( + self, + *, + saml_id: str, + ) -> ListSamlCertificatesResponse: + """ + List SAML certificates. + :param saml_id: ID of the SAML configuration. + :return: :class:`ListSamlCertificatesResponse ` + + Usage: + :: + + result = await api.list_saml_certificates( + saml_id="example", + ) + """ + + param_saml_id = validate_path_param("saml_id", saml_id) + + res = self._request( + "GET", + f"/iam/v1alpha1/saml/{param_saml_id}/certificates", + ) + + self._throw_on_error(res) + return unmarshal_ListSamlCertificatesResponse(res.json()) + + async def add_saml_certificate( + self, + *, + saml_id: str, + type_: SamlCertificateType, + content: str, + ) -> SamlCertificate: + """ + Add a SAML certificate. + :param saml_id: ID of the SAML configuration. + :param type_: Type of the SAML certificate. + :param content: Content of the SAML certificate. + :return: :class:`SamlCertificate ` + + Usage: + :: + + result = await api.add_saml_certificate( + saml_id="example", + type=SamlCertificateType.unknown_certificate_type, + content="example", + ) + """ + + param_saml_id = validate_path_param("saml_id", saml_id) + + res = self._request( + "POST", + f"/iam/v1alpha1/saml/{param_saml_id}/certificates", + body=marshal_AddSamlCertificateRequest( + AddSamlCertificateRequest( + saml_id=saml_id, + type_=type_, + content=content, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_SamlCertificate(res.json()) + + async def delete_saml_certificate( + self, + *, + certificate_id: str, + ) -> None: + """ + Delete a SAML certificate. + :param certificate_id: ID of the certificate to delete. + + Usage: + :: + + result = await api.delete_saml_certificate( + certificate_id="example", + ) + """ + + param_certificate_id = validate_path_param("certificate_id", certificate_id) + + res = self._request( + "DELETE", + f"/iam/v1alpha1/saml-certificates/{param_certificate_id}", + ) + + self._throw_on_error(res) diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py b/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py index e709230ee..cb1f31b8e 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py @@ -19,6 +19,7 @@ QuotumLimit, Quotum, SSHKey, + SamlCertificate, User, EncodedJWT, ConnectionConnectedOrganization, @@ -40,18 +41,22 @@ Rule, ListRulesResponse, ListSSHKeysResponse, + ListSamlCertificatesResponse, ListUsersResponse, MFAOTP, Organization, OrganizationSecuritySettings, + Saml, SetRulesResponse, ValidateUserMFAOTPResponse, AddGroupMemberRequest, AddGroupMembersRequest, + AddSamlCertificateRequest, CreateAPIKeyRequest, CreateApplicationRequest, CreateGroupRequest, CreateJWTRequest, + CreateOrganizationSamlRequest, RuleSpecs, CreatePolicyRequest, CreateSSHKeyRequest, @@ -66,6 +71,7 @@ UpdateAPIKeyRequest, UpdateApplicationRequest, UpdateGroupRequest, + UpdateOrganizationSamlRequest, UpdateOrganizationSecuritySettingsRequest, UpdatePolicyRequest, UpdateSSHKeyRequest, @@ -603,6 +609,39 @@ def unmarshal_SSHKey(data: Any) -> SSHKey: return SSHKey(**args) +def unmarshal_SamlCertificate(data: Any) -> SamlCertificate: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SamlCertificate' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + field = data.get("origin", None) + if field is not None: + args["origin"] = field + + field = data.get("content", None) + if field is not None: + args["content"] = field + + field = data.get("expires_at", None) + if field is not None: + args["expires_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["expires_at"] = None + + return SamlCertificate(**args) + + def unmarshal_User(data: Any) -> User: if not isinstance(data, dict): raise TypeError( @@ -1160,6 +1199,23 @@ def unmarshal_ListSSHKeysResponse(data: Any) -> ListSSHKeysResponse: return ListSSHKeysResponse(**args) +def unmarshal_ListSamlCertificatesResponse(data: Any) -> ListSamlCertificatesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListSamlCertificatesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("certificates", None) + if field is not None: + args["certificates"] = ( + [unmarshal_SamlCertificate(v) for v in field] if field is not None else None + ) + + return ListSamlCertificatesResponse(**args) + + def unmarshal_ListUsersResponse(data: Any) -> ListUsersResponse: if not isinstance(data, dict): raise TypeError( @@ -1244,6 +1300,29 @@ def unmarshal_OrganizationSecuritySettings(data: Any) -> OrganizationSecuritySet return OrganizationSecuritySettings(**args) +def unmarshal_Saml(data: Any) -> Saml: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Saml' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("entity_id", None) + if field is not None: + args["entity_id"] = field + + field = data.get("single_sign_on_url", None) + if field is not None: + args["single_sign_on_url"] = field + + return Saml(**args) + + def unmarshal_SetRulesResponse(data: Any) -> SetRulesResponse: if not isinstance(data, dict): raise TypeError( @@ -1308,6 +1387,21 @@ def marshal_AddGroupMembersRequest( return output +def marshal_AddSamlCertificateRequest( + request: AddSamlCertificateRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.type_ is not None: + output["type"] = str(request.type_) + + if request.content is not None: + output["content"] = request.content + + return output + + def marshal_CreateAPIKeyRequest( request: CreateAPIKeyRequest, defaults: ProfileDefaults, @@ -1395,6 +1489,21 @@ def marshal_CreateJWTRequest( return output +def marshal_CreateOrganizationSamlRequest( + request: CreateOrganizationSamlRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.entity_id is not None: + output["entity_id"] = request.entity_id + + if request.single_sign_on_url is not None: + output["single_sign_on_url"] = request.single_sign_on_url + + return output + + def marshal_RuleSpecs( request: RuleSpecs, defaults: ProfileDefaults, @@ -1671,6 +1780,21 @@ def marshal_UpdateGroupRequest( return output +def marshal_UpdateOrganizationSamlRequest( + request: UpdateOrganizationSamlRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.entity_id is not None: + output["entity_id"] = request.entity_id + + if request.single_sign_on_url is not None: + output["single_sign_on_url"] = request.single_sign_on_url + + return output + + def marshal_UpdateOrganizationSecuritySettingsRequest( request: UpdateOrganizationSecuritySettingsRequest, defaults: ProfileDefaults, diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/types.py b/scaleway-async/scaleway_async/iam/v1alpha1/types.py index 7860f33fa..e3b79b5f7 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/types.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/types.py @@ -187,6 +187,24 @@ def __str__(self) -> str: return str(self.value) +class SamlCertificateOrigin(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_CERTIFICATE_ORIGIN = "unknown_certificate_origin" + SCALEWAY = "scaleway" + IDENTITY_PROVIDER = "identity_provider" + + def __str__(self) -> str: + return str(self.value) + + +class SamlCertificateType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_CERTIFICATE_TYPE = "unknown_certificate_type" + SIGNING = "signing" + ENCRYPTION = "encryption" + + def __str__(self) -> str: + return str(self.value) + + class UserStatus(str, Enum, metaclass=StrEnumMeta): UNKNOWN_STATUS = "unknown_status" INVITATION_PENDING = "invitation_pending" @@ -825,6 +843,34 @@ class SSHKey: """ +@dataclass +class SamlCertificate: + id: str + """ + ID of the SAML certificate. + """ + + type_: SamlCertificateType + """ + Type of the SAML certificate. + """ + + origin: SamlCertificateOrigin + """ + Origin of the SAML certificate. + """ + + content: str + """ + Content of the SAML certificate. + """ + + expires_at: Optional[datetime] + """ + Date and time of the SAML certificate expiration. + """ + + @dataclass class User: id: str @@ -953,6 +999,24 @@ class AddGroupMembersRequest: """ +@dataclass +class AddSamlCertificateRequest: + saml_id: str + """ + ID of the SAML configuration. + """ + + type_: SamlCertificateType + """ + Type of the SAML certificate. + """ + + content: str + """ + Content of the SAML certificate. + """ + + @dataclass class ClonePolicyRequest: policy_id: str @@ -1039,6 +1103,24 @@ class CreateJWTRequest: """ +@dataclass +class CreateOrganizationSamlRequest: + entity_id: str + """ + Entity ID of the SAML Identity Provider. + """ + + single_sign_on_url: str + """ + Single Sign-On URL of the SAML Identity Provider. + """ + + organization_id: Optional[str] + """ + ID of the Organization. + """ + + @dataclass class CreatePolicyRequest: description: str @@ -1150,6 +1232,14 @@ class DeleteJWTRequest: """ +@dataclass +class DeleteOrganizationSamlRequest: + organization_id: Optional[str] + """ + ID of the Organization. + """ + + @dataclass class DeletePolicyRequest: policy_id: str @@ -1163,6 +1253,14 @@ class DeleteSSHKeyRequest: ssh_key_id: str +@dataclass +class DeleteSamlCertificateRequest: + certificate_id: str + """ + ID of the certificate to delete. + """ + + @dataclass class DeleteUserMFAOTPRequest: user_id: str @@ -1245,6 +1343,14 @@ class GetOrganizationRequest: """ +@dataclass +class GetOrganizationSamlRequest: + organization_id: Optional[str] + """ + ID of the Organization. + """ + + @dataclass class GetOrganizationSecuritySettingsRequest: organization_id: Optional[str] @@ -1874,6 +1980,22 @@ class ListSSHKeysResponse: """ +@dataclass +class ListSamlCertificatesRequest: + saml_id: str + """ + ID of the SAML configuration. + """ + + +@dataclass +class ListSamlCertificatesResponse: + certificates: List[SamlCertificate] + """ + List of SAML certificates. + """ + + @dataclass class ListUsersRequest: order_by: Optional[ListUsersRequestOrderBy] @@ -2012,6 +2134,24 @@ class RemoveUserConnectionRequest: """ +@dataclass +class Saml: + id: str + """ + ID of the SAML configuration. + """ + + entity_id: str + """ + Entity ID of the SAML Identity Provider. + """ + + single_sign_on_url: str + """ + Single Sign-On URL of the SAML Identity Provider. + """ + + @dataclass class SetGroupMembersRequest: group_id: str @@ -2127,6 +2267,24 @@ class UpdateGroupRequest: """ +@dataclass +class UpdateOrganizationSamlRequest: + organization_id: Optional[str] + """ + ID of the Organization. + """ + + entity_id: Optional[str] + """ + Entity ID of the SAML Identity Provider. + """ + + single_sign_on_url: Optional[str] + """ + Single Sign-On URL of the SAML Identity Provider. + """ + + @dataclass class UpdateOrganizationSecuritySettingsRequest: organization_id: Optional[str] diff --git a/scaleway/scaleway/iam/v1alpha1/__init__.py b/scaleway/scaleway/iam/v1alpha1/__init__.py index 089264bd2..ae8c64ef7 100644 --- a/scaleway/scaleway/iam/v1alpha1/__init__.py +++ b/scaleway/scaleway/iam/v1alpha1/__init__.py @@ -16,6 +16,8 @@ from .types import LogAction from .types import LogResourceType from .types import PermissionSetScopeType +from .types import SamlCertificateOrigin +from .types import SamlCertificateType from .types import UserStatus from .types import UserType from .types import ConnectionConnectedOrganization @@ -35,14 +37,17 @@ from .types import Quotum from .types import Rule from .types import SSHKey +from .types import SamlCertificate from .types import User from .types import AddGroupMemberRequest from .types import AddGroupMembersRequest +from .types import AddSamlCertificateRequest from .types import ClonePolicyRequest from .types import CreateAPIKeyRequest from .types import CreateApplicationRequest from .types import CreateGroupRequest from .types import CreateJWTRequest +from .types import CreateOrganizationSamlRequest from .types import CreatePolicyRequest from .types import CreateSSHKeyRequest from .types import CreateUserMFAOTPRequest @@ -51,8 +56,10 @@ from .types import DeleteApplicationRequest from .types import DeleteGroupRequest from .types import DeleteJWTRequest +from .types import DeleteOrganizationSamlRequest from .types import DeletePolicyRequest from .types import DeleteSSHKeyRequest +from .types import DeleteSamlCertificateRequest from .types import DeleteUserMFAOTPRequest from .types import DeleteUserRequest from .types import EncodedJWT @@ -62,6 +69,7 @@ from .types import GetJWTRequest from .types import GetLogRequest from .types import GetOrganizationRequest +from .types import GetOrganizationSamlRequest from .types import GetOrganizationSecuritySettingsRequest from .types import GetPolicyRequest from .types import GetQuotumRequest @@ -94,6 +102,8 @@ from .types import ListRulesResponse from .types import ListSSHKeysRequest from .types import ListSSHKeysResponse +from .types import ListSamlCertificatesRequest +from .types import ListSamlCertificatesResponse from .types import ListUsersRequest from .types import ListUsersResponse from .types import LockUserRequest @@ -103,6 +113,7 @@ from .types import OrganizationSecuritySettings from .types import RemoveGroupMemberRequest from .types import RemoveUserConnectionRequest +from .types import Saml from .types import SetGroupMembersRequest from .types import SetOrganizationAliasRequest from .types import SetRulesRequest @@ -111,6 +122,7 @@ from .types import UpdateAPIKeyRequest from .types import UpdateApplicationRequest from .types import UpdateGroupRequest +from .types import UpdateOrganizationSamlRequest from .types import UpdateOrganizationSecuritySettingsRequest from .types import UpdatePolicyRequest from .types import UpdateSSHKeyRequest @@ -138,6 +150,8 @@ "LogAction", "LogResourceType", "PermissionSetScopeType", + "SamlCertificateOrigin", + "SamlCertificateType", "UserStatus", "UserType", "ConnectionConnectedOrganization", @@ -157,14 +171,17 @@ "Quotum", "Rule", "SSHKey", + "SamlCertificate", "User", "AddGroupMemberRequest", "AddGroupMembersRequest", + "AddSamlCertificateRequest", "ClonePolicyRequest", "CreateAPIKeyRequest", "CreateApplicationRequest", "CreateGroupRequest", "CreateJWTRequest", + "CreateOrganizationSamlRequest", "CreatePolicyRequest", "CreateSSHKeyRequest", "CreateUserMFAOTPRequest", @@ -173,8 +190,10 @@ "DeleteApplicationRequest", "DeleteGroupRequest", "DeleteJWTRequest", + "DeleteOrganizationSamlRequest", "DeletePolicyRequest", "DeleteSSHKeyRequest", + "DeleteSamlCertificateRequest", "DeleteUserMFAOTPRequest", "DeleteUserRequest", "EncodedJWT", @@ -184,6 +203,7 @@ "GetJWTRequest", "GetLogRequest", "GetOrganizationRequest", + "GetOrganizationSamlRequest", "GetOrganizationSecuritySettingsRequest", "GetPolicyRequest", "GetQuotumRequest", @@ -216,6 +236,8 @@ "ListRulesResponse", "ListSSHKeysRequest", "ListSSHKeysResponse", + "ListSamlCertificatesRequest", + "ListSamlCertificatesResponse", "ListUsersRequest", "ListUsersResponse", "LockUserRequest", @@ -225,6 +247,7 @@ "OrganizationSecuritySettings", "RemoveGroupMemberRequest", "RemoveUserConnectionRequest", + "Saml", "SetGroupMembersRequest", "SetOrganizationAliasRequest", "SetRulesRequest", @@ -233,6 +256,7 @@ "UpdateAPIKeyRequest", "UpdateApplicationRequest", "UpdateGroupRequest", + "UpdateOrganizationSamlRequest", "UpdateOrganizationSecuritySettingsRequest", "UpdatePolicyRequest", "UpdateSSHKeyRequest", diff --git a/scaleway/scaleway/iam/v1alpha1/api.py b/scaleway/scaleway/iam/v1alpha1/api.py index 971015758..3cf88156a 100644 --- a/scaleway/scaleway/iam/v1alpha1/api.py +++ b/scaleway/scaleway/iam/v1alpha1/api.py @@ -26,15 +26,18 @@ ListUsersRequestOrderBy, LogAction, LogResourceType, + SamlCertificateType, UserType, APIKey, AddGroupMemberRequest, AddGroupMembersRequest, + AddSamlCertificateRequest, Application, CreateAPIKeyRequest, CreateApplicationRequest, CreateGroupRequest, CreateJWTRequest, + CreateOrganizationSamlRequest, CreatePolicyRequest, CreateSSHKeyRequest, CreateUserRequest, @@ -56,6 +59,7 @@ ListQuotaResponse, ListRulesResponse, ListSSHKeysResponse, + ListSamlCertificatesResponse, ListUsersResponse, Log, MFAOTP, @@ -69,6 +73,8 @@ Rule, RuleSpecs, SSHKey, + Saml, + SamlCertificate, SetGroupMembersRequest, SetOrganizationAliasRequest, SetRulesRequest, @@ -76,6 +82,7 @@ UpdateAPIKeyRequest, UpdateApplicationRequest, UpdateGroupRequest, + UpdateOrganizationSamlRequest, UpdateOrganizationSecuritySettingsRequest, UpdatePolicyRequest, UpdateSSHKeyRequest, @@ -95,6 +102,7 @@ unmarshal_Policy, unmarshal_Quotum, unmarshal_SSHKey, + unmarshal_SamlCertificate, unmarshal_User, unmarshal_EncodedJWT, unmarshal_GetUserConnectionsResponse, @@ -110,18 +118,22 @@ unmarshal_ListQuotaResponse, unmarshal_ListRulesResponse, unmarshal_ListSSHKeysResponse, + unmarshal_ListSamlCertificatesResponse, unmarshal_ListUsersResponse, unmarshal_MFAOTP, unmarshal_Organization, unmarshal_OrganizationSecuritySettings, + unmarshal_Saml, unmarshal_SetRulesResponse, unmarshal_ValidateUserMFAOTPResponse, marshal_AddGroupMemberRequest, marshal_AddGroupMembersRequest, + marshal_AddSamlCertificateRequest, marshal_CreateAPIKeyRequest, marshal_CreateApplicationRequest, marshal_CreateGroupRequest, marshal_CreateJWTRequest, + marshal_CreateOrganizationSamlRequest, marshal_CreatePolicyRequest, marshal_CreateSSHKeyRequest, marshal_CreateUserRequest, @@ -134,6 +146,7 @@ marshal_UpdateAPIKeyRequest, marshal_UpdateApplicationRequest, marshal_UpdateGroupRequest, + marshal_UpdateOrganizationSamlRequest, marshal_UpdateOrganizationSecuritySettingsRequest, marshal_UpdatePolicyRequest, marshal_UpdateSSHKeyRequest, @@ -3028,3 +3041,236 @@ def migrate_organization_guests( ) self._throw_on_error(res) + + def get_organization_saml( + self, + *, + organization_id: Optional[str] = None, + ) -> Saml: + """ + Get SAML Identity Provider configuration of an Organization. + :param organization_id: ID of the Organization. + :return: :class:`Saml ` + + Usage: + :: + + result = api.get_organization_saml() + """ + + param_organization_id = validate_path_param( + "organization_id", organization_id or self.client.default_organization_id + ) + + res = self._request( + "GET", + f"/iam/v1alpha1/organizations/{param_organization_id}/saml", + ) + + self._throw_on_error(res) + return unmarshal_Saml(res.json()) + + def create_organization_saml( + self, + *, + entity_id: str, + single_sign_on_url: str, + organization_id: Optional[str] = None, + ) -> Saml: + """ + Create a SAML Identity Provider configuration for an Organization. + :param entity_id: Entity ID of the SAML Identity Provider. + :param single_sign_on_url: Single Sign-On URL of the SAML Identity Provider. + :param organization_id: ID of the Organization. + :return: :class:`Saml ` + + Usage: + :: + + result = api.create_organization_saml( + entity_id="example", + single_sign_on_url="example", + ) + """ + + param_organization_id = validate_path_param( + "organization_id", organization_id or self.client.default_organization_id + ) + + res = self._request( + "POST", + f"/iam/v1alpha1/organizations/{param_organization_id}/saml", + body=marshal_CreateOrganizationSamlRequest( + CreateOrganizationSamlRequest( + entity_id=entity_id, + single_sign_on_url=single_sign_on_url, + organization_id=organization_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Saml(res.json()) + + def update_organization_saml( + self, + *, + organization_id: Optional[str] = None, + entity_id: Optional[str] = None, + single_sign_on_url: Optional[str] = None, + ) -> Saml: + """ + Update a SAML Identity Provider configuration for an Organization. + :param organization_id: ID of the Organization. + :param entity_id: Entity ID of the SAML Identity Provider. + :param single_sign_on_url: Single Sign-On URL of the SAML Identity Provider. + :return: :class:`Saml ` + + Usage: + :: + + result = api.update_organization_saml() + """ + + param_organization_id = validate_path_param( + "organization_id", organization_id or self.client.default_organization_id + ) + + res = self._request( + "PATCH", + f"/iam/v1alpha1/organizations/{param_organization_id}/saml", + body=marshal_UpdateOrganizationSamlRequest( + UpdateOrganizationSamlRequest( + organization_id=organization_id, + entity_id=entity_id, + single_sign_on_url=single_sign_on_url, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Saml(res.json()) + + def delete_organization_saml( + self, + *, + organization_id: Optional[str] = None, + ) -> None: + """ + Delete a SAML Identity Provider configuration for an Organization. + :param organization_id: ID of the Organization. + + Usage: + :: + + result = api.delete_organization_saml() + """ + + param_organization_id = validate_path_param( + "organization_id", organization_id or self.client.default_organization_id + ) + + res = self._request( + "DELETE", + f"/iam/v1alpha1/organizations/{param_organization_id}/saml", + ) + + self._throw_on_error(res) + + def list_saml_certificates( + self, + *, + saml_id: str, + ) -> ListSamlCertificatesResponse: + """ + List SAML certificates. + :param saml_id: ID of the SAML configuration. + :return: :class:`ListSamlCertificatesResponse ` + + Usage: + :: + + result = api.list_saml_certificates( + saml_id="example", + ) + """ + + param_saml_id = validate_path_param("saml_id", saml_id) + + res = self._request( + "GET", + f"/iam/v1alpha1/saml/{param_saml_id}/certificates", + ) + + self._throw_on_error(res) + return unmarshal_ListSamlCertificatesResponse(res.json()) + + def add_saml_certificate( + self, + *, + saml_id: str, + type_: SamlCertificateType, + content: str, + ) -> SamlCertificate: + """ + Add a SAML certificate. + :param saml_id: ID of the SAML configuration. + :param type_: Type of the SAML certificate. + :param content: Content of the SAML certificate. + :return: :class:`SamlCertificate ` + + Usage: + :: + + result = api.add_saml_certificate( + saml_id="example", + type=SamlCertificateType.unknown_certificate_type, + content="example", + ) + """ + + param_saml_id = validate_path_param("saml_id", saml_id) + + res = self._request( + "POST", + f"/iam/v1alpha1/saml/{param_saml_id}/certificates", + body=marshal_AddSamlCertificateRequest( + AddSamlCertificateRequest( + saml_id=saml_id, + type_=type_, + content=content, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_SamlCertificate(res.json()) + + def delete_saml_certificate( + self, + *, + certificate_id: str, + ) -> None: + """ + Delete a SAML certificate. + :param certificate_id: ID of the certificate to delete. + + Usage: + :: + + result = api.delete_saml_certificate( + certificate_id="example", + ) + """ + + param_certificate_id = validate_path_param("certificate_id", certificate_id) + + res = self._request( + "DELETE", + f"/iam/v1alpha1/saml-certificates/{param_certificate_id}", + ) + + self._throw_on_error(res) diff --git a/scaleway/scaleway/iam/v1alpha1/marshalling.py b/scaleway/scaleway/iam/v1alpha1/marshalling.py index e709230ee..cb1f31b8e 100644 --- a/scaleway/scaleway/iam/v1alpha1/marshalling.py +++ b/scaleway/scaleway/iam/v1alpha1/marshalling.py @@ -19,6 +19,7 @@ QuotumLimit, Quotum, SSHKey, + SamlCertificate, User, EncodedJWT, ConnectionConnectedOrganization, @@ -40,18 +41,22 @@ Rule, ListRulesResponse, ListSSHKeysResponse, + ListSamlCertificatesResponse, ListUsersResponse, MFAOTP, Organization, OrganizationSecuritySettings, + Saml, SetRulesResponse, ValidateUserMFAOTPResponse, AddGroupMemberRequest, AddGroupMembersRequest, + AddSamlCertificateRequest, CreateAPIKeyRequest, CreateApplicationRequest, CreateGroupRequest, CreateJWTRequest, + CreateOrganizationSamlRequest, RuleSpecs, CreatePolicyRequest, CreateSSHKeyRequest, @@ -66,6 +71,7 @@ UpdateAPIKeyRequest, UpdateApplicationRequest, UpdateGroupRequest, + UpdateOrganizationSamlRequest, UpdateOrganizationSecuritySettingsRequest, UpdatePolicyRequest, UpdateSSHKeyRequest, @@ -603,6 +609,39 @@ def unmarshal_SSHKey(data: Any) -> SSHKey: return SSHKey(**args) +def unmarshal_SamlCertificate(data: Any) -> SamlCertificate: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SamlCertificate' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + field = data.get("origin", None) + if field is not None: + args["origin"] = field + + field = data.get("content", None) + if field is not None: + args["content"] = field + + field = data.get("expires_at", None) + if field is not None: + args["expires_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["expires_at"] = None + + return SamlCertificate(**args) + + def unmarshal_User(data: Any) -> User: if not isinstance(data, dict): raise TypeError( @@ -1160,6 +1199,23 @@ def unmarshal_ListSSHKeysResponse(data: Any) -> ListSSHKeysResponse: return ListSSHKeysResponse(**args) +def unmarshal_ListSamlCertificatesResponse(data: Any) -> ListSamlCertificatesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListSamlCertificatesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("certificates", None) + if field is not None: + args["certificates"] = ( + [unmarshal_SamlCertificate(v) for v in field] if field is not None else None + ) + + return ListSamlCertificatesResponse(**args) + + def unmarshal_ListUsersResponse(data: Any) -> ListUsersResponse: if not isinstance(data, dict): raise TypeError( @@ -1244,6 +1300,29 @@ def unmarshal_OrganizationSecuritySettings(data: Any) -> OrganizationSecuritySet return OrganizationSecuritySettings(**args) +def unmarshal_Saml(data: Any) -> Saml: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Saml' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("entity_id", None) + if field is not None: + args["entity_id"] = field + + field = data.get("single_sign_on_url", None) + if field is not None: + args["single_sign_on_url"] = field + + return Saml(**args) + + def unmarshal_SetRulesResponse(data: Any) -> SetRulesResponse: if not isinstance(data, dict): raise TypeError( @@ -1308,6 +1387,21 @@ def marshal_AddGroupMembersRequest( return output +def marshal_AddSamlCertificateRequest( + request: AddSamlCertificateRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.type_ is not None: + output["type"] = str(request.type_) + + if request.content is not None: + output["content"] = request.content + + return output + + def marshal_CreateAPIKeyRequest( request: CreateAPIKeyRequest, defaults: ProfileDefaults, @@ -1395,6 +1489,21 @@ def marshal_CreateJWTRequest( return output +def marshal_CreateOrganizationSamlRequest( + request: CreateOrganizationSamlRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.entity_id is not None: + output["entity_id"] = request.entity_id + + if request.single_sign_on_url is not None: + output["single_sign_on_url"] = request.single_sign_on_url + + return output + + def marshal_RuleSpecs( request: RuleSpecs, defaults: ProfileDefaults, @@ -1671,6 +1780,21 @@ def marshal_UpdateGroupRequest( return output +def marshal_UpdateOrganizationSamlRequest( + request: UpdateOrganizationSamlRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.entity_id is not None: + output["entity_id"] = request.entity_id + + if request.single_sign_on_url is not None: + output["single_sign_on_url"] = request.single_sign_on_url + + return output + + def marshal_UpdateOrganizationSecuritySettingsRequest( request: UpdateOrganizationSecuritySettingsRequest, defaults: ProfileDefaults, diff --git a/scaleway/scaleway/iam/v1alpha1/types.py b/scaleway/scaleway/iam/v1alpha1/types.py index 7860f33fa..e3b79b5f7 100644 --- a/scaleway/scaleway/iam/v1alpha1/types.py +++ b/scaleway/scaleway/iam/v1alpha1/types.py @@ -187,6 +187,24 @@ def __str__(self) -> str: return str(self.value) +class SamlCertificateOrigin(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_CERTIFICATE_ORIGIN = "unknown_certificate_origin" + SCALEWAY = "scaleway" + IDENTITY_PROVIDER = "identity_provider" + + def __str__(self) -> str: + return str(self.value) + + +class SamlCertificateType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_CERTIFICATE_TYPE = "unknown_certificate_type" + SIGNING = "signing" + ENCRYPTION = "encryption" + + def __str__(self) -> str: + return str(self.value) + + class UserStatus(str, Enum, metaclass=StrEnumMeta): UNKNOWN_STATUS = "unknown_status" INVITATION_PENDING = "invitation_pending" @@ -825,6 +843,34 @@ class SSHKey: """ +@dataclass +class SamlCertificate: + id: str + """ + ID of the SAML certificate. + """ + + type_: SamlCertificateType + """ + Type of the SAML certificate. + """ + + origin: SamlCertificateOrigin + """ + Origin of the SAML certificate. + """ + + content: str + """ + Content of the SAML certificate. + """ + + expires_at: Optional[datetime] + """ + Date and time of the SAML certificate expiration. + """ + + @dataclass class User: id: str @@ -953,6 +999,24 @@ class AddGroupMembersRequest: """ +@dataclass +class AddSamlCertificateRequest: + saml_id: str + """ + ID of the SAML configuration. + """ + + type_: SamlCertificateType + """ + Type of the SAML certificate. + """ + + content: str + """ + Content of the SAML certificate. + """ + + @dataclass class ClonePolicyRequest: policy_id: str @@ -1039,6 +1103,24 @@ class CreateJWTRequest: """ +@dataclass +class CreateOrganizationSamlRequest: + entity_id: str + """ + Entity ID of the SAML Identity Provider. + """ + + single_sign_on_url: str + """ + Single Sign-On URL of the SAML Identity Provider. + """ + + organization_id: Optional[str] + """ + ID of the Organization. + """ + + @dataclass class CreatePolicyRequest: description: str @@ -1150,6 +1232,14 @@ class DeleteJWTRequest: """ +@dataclass +class DeleteOrganizationSamlRequest: + organization_id: Optional[str] + """ + ID of the Organization. + """ + + @dataclass class DeletePolicyRequest: policy_id: str @@ -1163,6 +1253,14 @@ class DeleteSSHKeyRequest: ssh_key_id: str +@dataclass +class DeleteSamlCertificateRequest: + certificate_id: str + """ + ID of the certificate to delete. + """ + + @dataclass class DeleteUserMFAOTPRequest: user_id: str @@ -1245,6 +1343,14 @@ class GetOrganizationRequest: """ +@dataclass +class GetOrganizationSamlRequest: + organization_id: Optional[str] + """ + ID of the Organization. + """ + + @dataclass class GetOrganizationSecuritySettingsRequest: organization_id: Optional[str] @@ -1874,6 +1980,22 @@ class ListSSHKeysResponse: """ +@dataclass +class ListSamlCertificatesRequest: + saml_id: str + """ + ID of the SAML configuration. + """ + + +@dataclass +class ListSamlCertificatesResponse: + certificates: List[SamlCertificate] + """ + List of SAML certificates. + """ + + @dataclass class ListUsersRequest: order_by: Optional[ListUsersRequestOrderBy] @@ -2012,6 +2134,24 @@ class RemoveUserConnectionRequest: """ +@dataclass +class Saml: + id: str + """ + ID of the SAML configuration. + """ + + entity_id: str + """ + Entity ID of the SAML Identity Provider. + """ + + single_sign_on_url: str + """ + Single Sign-On URL of the SAML Identity Provider. + """ + + @dataclass class SetGroupMembersRequest: group_id: str @@ -2127,6 +2267,24 @@ class UpdateGroupRequest: """ +@dataclass +class UpdateOrganizationSamlRequest: + organization_id: Optional[str] + """ + ID of the Organization. + """ + + entity_id: Optional[str] + """ + Entity ID of the SAML Identity Provider. + """ + + single_sign_on_url: Optional[str] + """ + Single Sign-On URL of the SAML Identity Provider. + """ + + @dataclass class UpdateOrganizationSecuritySettingsRequest: organization_id: Optional[str]