Skip to content

feat(iam): add UpdateUserPassword method #707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scaleway-async/scaleway_async/iam/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -178,6 +179,7 @@
"UpdateGroupRequest",
"UpdatePolicyRequest",
"UpdateSSHKeyRequest",
"UpdateUserPasswordRequest",
"UpdateUserRequest",
"IamV1Alpha1API",
]
43 changes: 43 additions & 0 deletions scaleway-async/scaleway_async/iam/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
UpdateGroupRequest,
UpdatePolicyRequest,
UpdateSSHKeyRequest,
UpdateUserPasswordRequest,
UpdateUserRequest,
User,
)
Expand Down Expand Up @@ -111,6 +112,7 @@
marshal_UpdateGroupRequest,
marshal_UpdatePolicyRequest,
marshal_UpdateSSHKeyRequest,
marshal_UpdateUserPasswordRequest,
marshal_UpdateUserRequest,
)

Expand Down Expand Up @@ -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 <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,
*,
Expand Down
16 changes: 16 additions & 0 deletions scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
UpdateGroupRequest,
UpdatePolicyRequest,
UpdateSSHKeyRequest,
UpdateUserPasswordRequest,
UpdateUserRequest,
)

Expand Down Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions scaleway-async/scaleway_async/iam/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1843,6 +1843,15 @@ class UpdateSSHKeyRequest:
"""


@dataclass
class UpdateUserPasswordRequest:
user_id: str

password: str

send_email: bool


@dataclass
class UpdateUserRequest:
user_id: str
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/iam/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -178,6 +179,7 @@
"UpdateGroupRequest",
"UpdatePolicyRequest",
"UpdateSSHKeyRequest",
"UpdateUserPasswordRequest",
"UpdateUserRequest",
"IamV1Alpha1API",
]
43 changes: 43 additions & 0 deletions scaleway/scaleway/iam/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
UpdateGroupRequest,
UpdatePolicyRequest,
UpdateSSHKeyRequest,
UpdateUserPasswordRequest,
UpdateUserRequest,
User,
)
Expand Down Expand Up @@ -111,6 +112,7 @@
marshal_UpdateGroupRequest,
marshal_UpdatePolicyRequest,
marshal_UpdateSSHKeyRequest,
marshal_UpdateUserPasswordRequest,
marshal_UpdateUserRequest,
)

Expand Down Expand Up @@ -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 <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,
*,
Expand Down
16 changes: 16 additions & 0 deletions scaleway/scaleway/iam/v1alpha1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
UpdateGroupRequest,
UpdatePolicyRequest,
UpdateSSHKeyRequest,
UpdateUserPasswordRequest,
UpdateUserRequest,
)

Expand Down Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions scaleway/scaleway/iam/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1843,6 +1843,15 @@ class UpdateSSHKeyRequest:
"""


@dataclass
class UpdateUserPasswordRequest:
user_id: str

password: str

send_email: bool


@dataclass
class UpdateUserRequest:
user_id: str
Expand Down