diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py b/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py index fa5cccbeb..a59f33617 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py @@ -87,6 +87,7 @@ from .types import UpdateGroupRequest from .types import UpdatePolicyRequest from .types import UpdateSSHKeyRequest +from .types import UpdateUserPasswordRequest from .types import UpdateUserRequest from .api import IamV1Alpha1API @@ -178,6 +179,7 @@ "UpdateGroupRequest", "UpdatePolicyRequest", "UpdateSSHKeyRequest", + "UpdateUserPasswordRequest", "UpdateUserRequest", "IamV1Alpha1API", ] diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/api.py b/scaleway-async/scaleway_async/iam/v1alpha1/api.py index ff0df6fd5..d01f497fc 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/api.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/api.py @@ -68,6 +68,7 @@ UpdateGroupRequest, UpdatePolicyRequest, UpdateSSHKeyRequest, + UpdateUserPasswordRequest, UpdateUserRequest, User, ) @@ -111,6 +112,7 @@ marshal_UpdateGroupRequest, marshal_UpdatePolicyRequest, marshal_UpdateSSHKeyRequest, + marshal_UpdateUserPasswordRequest, marshal_UpdateUserRequest, ) @@ -574,6 +576,47 @@ async def create_user( self._throw_on_error(res) return unmarshal_User(res.json()) + async def update_user_password( + self, + *, + user_id: str, + password: str, + send_email: bool, + ) -> User: + """ + :param user_id: + :param password: + :param send_email: + :return: :class:`User ` + + Usage: + :: + + result = await api.update_user_password( + user_id="example", + password="example", + send_email=False, + ) + """ + + param_user_id = validate_path_param("user_id", user_id) + + res = self._request( + "POST", + f"/iam/v1alpha1/users/{param_user_id}/update-password", + body=marshal_UpdateUserPasswordRequest( + UpdateUserPasswordRequest( + user_id=user_id, + password=password, + send_email=send_email, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_User(res.json()) + async def list_applications( self, *, diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py b/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py index e64f626ff..042c86708 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py @@ -53,6 +53,7 @@ UpdateGroupRequest, UpdatePolicyRequest, UpdateSSHKeyRequest, + UpdateUserPasswordRequest, UpdateUserRequest, ) @@ -1350,6 +1351,21 @@ def marshal_UpdateSSHKeyRequest( return output +def marshal_UpdateUserPasswordRequest( + request: UpdateUserPasswordRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.password is not None: + output["password"] = request.password + + if request.send_email is not None: + output["send_email"] = request.send_email + + return output + + def marshal_UpdateUserRequest( request: UpdateUserRequest, defaults: ProfileDefaults, diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/types.py b/scaleway-async/scaleway_async/iam/v1alpha1/types.py index 7b5a9f8f5..5c1d9df71 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/types.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/types.py @@ -1843,6 +1843,15 @@ class UpdateSSHKeyRequest: """ +@dataclass +class UpdateUserPasswordRequest: + user_id: str + + password: str + + send_email: bool + + @dataclass class UpdateUserRequest: user_id: str diff --git a/scaleway/scaleway/iam/v1alpha1/__init__.py b/scaleway/scaleway/iam/v1alpha1/__init__.py index fa5cccbeb..a59f33617 100644 --- a/scaleway/scaleway/iam/v1alpha1/__init__.py +++ b/scaleway/scaleway/iam/v1alpha1/__init__.py @@ -87,6 +87,7 @@ from .types import UpdateGroupRequest from .types import UpdatePolicyRequest from .types import UpdateSSHKeyRequest +from .types import UpdateUserPasswordRequest from .types import UpdateUserRequest from .api import IamV1Alpha1API @@ -178,6 +179,7 @@ "UpdateGroupRequest", "UpdatePolicyRequest", "UpdateSSHKeyRequest", + "UpdateUserPasswordRequest", "UpdateUserRequest", "IamV1Alpha1API", ] diff --git a/scaleway/scaleway/iam/v1alpha1/api.py b/scaleway/scaleway/iam/v1alpha1/api.py index bd034c409..602db99d8 100644 --- a/scaleway/scaleway/iam/v1alpha1/api.py +++ b/scaleway/scaleway/iam/v1alpha1/api.py @@ -68,6 +68,7 @@ UpdateGroupRequest, UpdatePolicyRequest, UpdateSSHKeyRequest, + UpdateUserPasswordRequest, UpdateUserRequest, User, ) @@ -111,6 +112,7 @@ marshal_UpdateGroupRequest, marshal_UpdatePolicyRequest, marshal_UpdateSSHKeyRequest, + marshal_UpdateUserPasswordRequest, marshal_UpdateUserRequest, ) @@ -574,6 +576,47 @@ def create_user( self._throw_on_error(res) return unmarshal_User(res.json()) + def update_user_password( + self, + *, + user_id: str, + password: str, + send_email: bool, + ) -> User: + """ + :param user_id: + :param password: + :param send_email: + :return: :class:`User ` + + Usage: + :: + + result = api.update_user_password( + user_id="example", + password="example", + send_email=False, + ) + """ + + param_user_id = validate_path_param("user_id", user_id) + + res = self._request( + "POST", + f"/iam/v1alpha1/users/{param_user_id}/update-password", + body=marshal_UpdateUserPasswordRequest( + UpdateUserPasswordRequest( + user_id=user_id, + password=password, + send_email=send_email, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_User(res.json()) + def list_applications( self, *, diff --git a/scaleway/scaleway/iam/v1alpha1/marshalling.py b/scaleway/scaleway/iam/v1alpha1/marshalling.py index e64f626ff..042c86708 100644 --- a/scaleway/scaleway/iam/v1alpha1/marshalling.py +++ b/scaleway/scaleway/iam/v1alpha1/marshalling.py @@ -53,6 +53,7 @@ UpdateGroupRequest, UpdatePolicyRequest, UpdateSSHKeyRequest, + UpdateUserPasswordRequest, UpdateUserRequest, ) @@ -1350,6 +1351,21 @@ def marshal_UpdateSSHKeyRequest( return output +def marshal_UpdateUserPasswordRequest( + request: UpdateUserPasswordRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.password is not None: + output["password"] = request.password + + if request.send_email is not None: + output["send_email"] = request.send_email + + return output + + def marshal_UpdateUserRequest( request: UpdateUserRequest, defaults: ProfileDefaults, diff --git a/scaleway/scaleway/iam/v1alpha1/types.py b/scaleway/scaleway/iam/v1alpha1/types.py index 7b5a9f8f5..5c1d9df71 100644 --- a/scaleway/scaleway/iam/v1alpha1/types.py +++ b/scaleway/scaleway/iam/v1alpha1/types.py @@ -1843,6 +1843,15 @@ class UpdateSSHKeyRequest: """ +@dataclass +class UpdateUserPasswordRequest: + user_id: str + + password: str + + send_email: bool + + @dataclass class UpdateUserRequest: user_id: str