diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py b/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py index 10a9a31b5..089264bd2 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py @@ -61,6 +61,7 @@ from .types import GetGroupRequest from .types import GetJWTRequest from .types import GetLogRequest +from .types import GetOrganizationRequest from .types import GetOrganizationSecuritySettingsRequest from .types import GetPolicyRequest from .types import GetQuotumRequest @@ -98,10 +99,12 @@ from .types import LockUserRequest from .types import MFAOTP from .types import MigrateOrganizationGuestsRequest +from .types import Organization from .types import OrganizationSecuritySettings from .types import RemoveGroupMemberRequest from .types import RemoveUserConnectionRequest from .types import SetGroupMembersRequest +from .types import SetOrganizationAliasRequest from .types import SetRulesRequest from .types import SetRulesResponse from .types import UnlockUserRequest @@ -180,6 +183,7 @@ "GetGroupRequest", "GetJWTRequest", "GetLogRequest", + "GetOrganizationRequest", "GetOrganizationSecuritySettingsRequest", "GetPolicyRequest", "GetQuotumRequest", @@ -217,10 +221,12 @@ "LockUserRequest", "MFAOTP", "MigrateOrganizationGuestsRequest", + "Organization", "OrganizationSecuritySettings", "RemoveGroupMemberRequest", "RemoveUserConnectionRequest", "SetGroupMembersRequest", + "SetOrganizationAliasRequest", "SetRulesRequest", "SetRulesResponse", "UnlockUserRequest", diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/api.py b/scaleway-async/scaleway_async/iam/v1alpha1/api.py index 905830920..b450d5bde 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/api.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/api.py @@ -59,6 +59,7 @@ ListUsersResponse, Log, MFAOTP, + Organization, OrganizationSecuritySettings, PermissionSet, Policy, @@ -69,6 +70,7 @@ RuleSpecs, SSHKey, SetGroupMembersRequest, + SetOrganizationAliasRequest, SetRulesRequest, SetRulesResponse, UpdateAPIKeyRequest, @@ -110,6 +112,7 @@ unmarshal_ListSSHKeysResponse, unmarshal_ListUsersResponse, unmarshal_MFAOTP, + unmarshal_Organization, unmarshal_OrganizationSecuritySettings, unmarshal_SetRulesResponse, unmarshal_ValidateUserMFAOTPResponse, @@ -126,6 +129,7 @@ marshal_RemoveGroupMemberRequest, marshal_RemoveUserConnectionRequest, marshal_SetGroupMembersRequest, + marshal_SetOrganizationAliasRequest, marshal_SetRulesRequest, marshal_UpdateAPIKeyRequest, marshal_UpdateApplicationRequest, @@ -2931,6 +2935,74 @@ async def update_organization_security_settings( self._throw_on_error(res) return unmarshal_OrganizationSecuritySettings(res.json()) + async def set_organization_alias( + self, + *, + alias: str, + organization_id: Optional[str] = None, + ) -> Organization: + """ + Set your Organization's alias. + This will fail if an alias has already been defined. Please contact support if you need to change your Organization's alias. + :param alias: Alias of the Organization. + :param organization_id: ID of the Organization. + :return: :class:`Organization ` + + Usage: + :: + + result = await api.set_organization_alias( + alias="example", + ) + """ + + param_organization_id = validate_path_param( + "organization_id", organization_id or self.client.default_organization_id + ) + + res = self._request( + "PUT", + f"/iam/v1alpha1/organizations/{param_organization_id}/alias", + body=marshal_SetOrganizationAliasRequest( + SetOrganizationAliasRequest( + alias=alias, + organization_id=organization_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Organization(res.json()) + + async def get_organization( + self, + *, + organization_id: Optional[str] = None, + ) -> Organization: + """ + Get your Organization's IAM information. + :param organization_id: ID of the Organization. + :return: :class:`Organization ` + + Usage: + :: + + result = await api.get_organization() + """ + + 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}", + ) + + self._throw_on_error(res) + return unmarshal_Organization(res.json()) + async def migrate_organization_guests( self, *, diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py b/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py index 2e818d91a..e709230ee 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py @@ -42,6 +42,7 @@ ListSSHKeysResponse, ListUsersResponse, MFAOTP, + Organization, OrganizationSecuritySettings, SetRulesResponse, ValidateUserMFAOTPResponse, @@ -60,6 +61,7 @@ RemoveGroupMemberRequest, RemoveUserConnectionRequest, SetGroupMembersRequest, + SetOrganizationAliasRequest, SetRulesRequest, UpdateAPIKeyRequest, UpdateApplicationRequest, @@ -1194,6 +1196,29 @@ def unmarshal_MFAOTP(data: Any) -> MFAOTP: return MFAOTP(**args) +def unmarshal_Organization(data: Any) -> Organization: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Organization' 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("name", None) + if field is not None: + args["name"] = field + + field = data.get("alias", None) + if field is not None: + args["alias"] = field + + return Organization(**args) + + def unmarshal_OrganizationSecuritySettings(data: Any) -> OrganizationSecuritySettings: if not isinstance(data, dict): raise TypeError( @@ -1568,6 +1593,18 @@ def marshal_SetGroupMembersRequest( return output +def marshal_SetOrganizationAliasRequest( + request: SetOrganizationAliasRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.alias is not None: + output["alias"] = request.alias + + return output + + def marshal_SetRulesRequest( request: SetRulesRequest, defaults: ProfileDefaults, diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/types.py b/scaleway-async/scaleway_async/iam/v1alpha1/types.py index eb811d41e..7860f33fa 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/types.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/types.py @@ -1237,6 +1237,14 @@ class GetLogRequest: """ +@dataclass +class GetOrganizationRequest: + organization_id: Optional[str] + """ + ID of the Organization. + """ + + @dataclass class GetOrganizationSecuritySettingsRequest: organization_id: Optional[str] @@ -1943,6 +1951,24 @@ class MigrateOrganizationGuestsRequest: """ +@dataclass +class Organization: + id: str + """ + ID of the Organization. + """ + + name: str + """ + Name of the Organization. + """ + + alias: str + """ + Alias of the Organization. + """ + + @dataclass class OrganizationSecuritySettings: enforce_password_renewal: bool @@ -1995,6 +2021,19 @@ class SetGroupMembersRequest: application_ids: List[str] +@dataclass +class SetOrganizationAliasRequest: + alias: str + """ + Alias of the Organization. + """ + + organization_id: Optional[str] + """ + ID of the Organization. + """ + + @dataclass class SetRulesRequest: policy_id: str diff --git a/scaleway/scaleway/iam/v1alpha1/__init__.py b/scaleway/scaleway/iam/v1alpha1/__init__.py index 10a9a31b5..089264bd2 100644 --- a/scaleway/scaleway/iam/v1alpha1/__init__.py +++ b/scaleway/scaleway/iam/v1alpha1/__init__.py @@ -61,6 +61,7 @@ from .types import GetGroupRequest from .types import GetJWTRequest from .types import GetLogRequest +from .types import GetOrganizationRequest from .types import GetOrganizationSecuritySettingsRequest from .types import GetPolicyRequest from .types import GetQuotumRequest @@ -98,10 +99,12 @@ from .types import LockUserRequest from .types import MFAOTP from .types import MigrateOrganizationGuestsRequest +from .types import Organization from .types import OrganizationSecuritySettings from .types import RemoveGroupMemberRequest from .types import RemoveUserConnectionRequest from .types import SetGroupMembersRequest +from .types import SetOrganizationAliasRequest from .types import SetRulesRequest from .types import SetRulesResponse from .types import UnlockUserRequest @@ -180,6 +183,7 @@ "GetGroupRequest", "GetJWTRequest", "GetLogRequest", + "GetOrganizationRequest", "GetOrganizationSecuritySettingsRequest", "GetPolicyRequest", "GetQuotumRequest", @@ -217,10 +221,12 @@ "LockUserRequest", "MFAOTP", "MigrateOrganizationGuestsRequest", + "Organization", "OrganizationSecuritySettings", "RemoveGroupMemberRequest", "RemoveUserConnectionRequest", "SetGroupMembersRequest", + "SetOrganizationAliasRequest", "SetRulesRequest", "SetRulesResponse", "UnlockUserRequest", diff --git a/scaleway/scaleway/iam/v1alpha1/api.py b/scaleway/scaleway/iam/v1alpha1/api.py index 8ef6231b6..971015758 100644 --- a/scaleway/scaleway/iam/v1alpha1/api.py +++ b/scaleway/scaleway/iam/v1alpha1/api.py @@ -59,6 +59,7 @@ ListUsersResponse, Log, MFAOTP, + Organization, OrganizationSecuritySettings, PermissionSet, Policy, @@ -69,6 +70,7 @@ RuleSpecs, SSHKey, SetGroupMembersRequest, + SetOrganizationAliasRequest, SetRulesRequest, SetRulesResponse, UpdateAPIKeyRequest, @@ -110,6 +112,7 @@ unmarshal_ListSSHKeysResponse, unmarshal_ListUsersResponse, unmarshal_MFAOTP, + unmarshal_Organization, unmarshal_OrganizationSecuritySettings, unmarshal_SetRulesResponse, unmarshal_ValidateUserMFAOTPResponse, @@ -126,6 +129,7 @@ marshal_RemoveGroupMemberRequest, marshal_RemoveUserConnectionRequest, marshal_SetGroupMembersRequest, + marshal_SetOrganizationAliasRequest, marshal_SetRulesRequest, marshal_UpdateAPIKeyRequest, marshal_UpdateApplicationRequest, @@ -2931,6 +2935,74 @@ def update_organization_security_settings( self._throw_on_error(res) return unmarshal_OrganizationSecuritySettings(res.json()) + def set_organization_alias( + self, + *, + alias: str, + organization_id: Optional[str] = None, + ) -> Organization: + """ + Set your Organization's alias. + This will fail if an alias has already been defined. Please contact support if you need to change your Organization's alias. + :param alias: Alias of the Organization. + :param organization_id: ID of the Organization. + :return: :class:`Organization ` + + Usage: + :: + + result = api.set_organization_alias( + alias="example", + ) + """ + + param_organization_id = validate_path_param( + "organization_id", organization_id or self.client.default_organization_id + ) + + res = self._request( + "PUT", + f"/iam/v1alpha1/organizations/{param_organization_id}/alias", + body=marshal_SetOrganizationAliasRequest( + SetOrganizationAliasRequest( + alias=alias, + organization_id=organization_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Organization(res.json()) + + def get_organization( + self, + *, + organization_id: Optional[str] = None, + ) -> Organization: + """ + Get your Organization's IAM information. + :param organization_id: ID of the Organization. + :return: :class:`Organization ` + + Usage: + :: + + result = api.get_organization() + """ + + 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}", + ) + + self._throw_on_error(res) + return unmarshal_Organization(res.json()) + def migrate_organization_guests( self, *, diff --git a/scaleway/scaleway/iam/v1alpha1/marshalling.py b/scaleway/scaleway/iam/v1alpha1/marshalling.py index 2e818d91a..e709230ee 100644 --- a/scaleway/scaleway/iam/v1alpha1/marshalling.py +++ b/scaleway/scaleway/iam/v1alpha1/marshalling.py @@ -42,6 +42,7 @@ ListSSHKeysResponse, ListUsersResponse, MFAOTP, + Organization, OrganizationSecuritySettings, SetRulesResponse, ValidateUserMFAOTPResponse, @@ -60,6 +61,7 @@ RemoveGroupMemberRequest, RemoveUserConnectionRequest, SetGroupMembersRequest, + SetOrganizationAliasRequest, SetRulesRequest, UpdateAPIKeyRequest, UpdateApplicationRequest, @@ -1194,6 +1196,29 @@ def unmarshal_MFAOTP(data: Any) -> MFAOTP: return MFAOTP(**args) +def unmarshal_Organization(data: Any) -> Organization: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Organization' 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("name", None) + if field is not None: + args["name"] = field + + field = data.get("alias", None) + if field is not None: + args["alias"] = field + + return Organization(**args) + + def unmarshal_OrganizationSecuritySettings(data: Any) -> OrganizationSecuritySettings: if not isinstance(data, dict): raise TypeError( @@ -1568,6 +1593,18 @@ def marshal_SetGroupMembersRequest( return output +def marshal_SetOrganizationAliasRequest( + request: SetOrganizationAliasRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.alias is not None: + output["alias"] = request.alias + + return output + + def marshal_SetRulesRequest( request: SetRulesRequest, defaults: ProfileDefaults, diff --git a/scaleway/scaleway/iam/v1alpha1/types.py b/scaleway/scaleway/iam/v1alpha1/types.py index eb811d41e..7860f33fa 100644 --- a/scaleway/scaleway/iam/v1alpha1/types.py +++ b/scaleway/scaleway/iam/v1alpha1/types.py @@ -1237,6 +1237,14 @@ class GetLogRequest: """ +@dataclass +class GetOrganizationRequest: + organization_id: Optional[str] + """ + ID of the Organization. + """ + + @dataclass class GetOrganizationSecuritySettingsRequest: organization_id: Optional[str] @@ -1943,6 +1951,24 @@ class MigrateOrganizationGuestsRequest: """ +@dataclass +class Organization: + id: str + """ + ID of the Organization. + """ + + name: str + """ + Name of the Organization. + """ + + alias: str + """ + Alias of the Organization. + """ + + @dataclass class OrganizationSecuritySettings: enforce_password_renewal: bool @@ -1995,6 +2021,19 @@ class SetGroupMembersRequest: application_ids: List[str] +@dataclass +class SetOrganizationAliasRequest: + alias: str + """ + Alias of the Organization. + """ + + organization_id: Optional[str] + """ + ID of the Organization. + """ + + @dataclass class SetRulesRequest: policy_id: str