diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py b/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py index bb4d8d674..a50d008a6 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py @@ -1,6 +1,7 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. from .types import BearerType +from .types import GracePeriodType from .types import ListAPIKeysRequestOrderBy from .types import ListApplicationsRequestOrderBy from .types import ListGroupsRequestOrderBy @@ -21,6 +22,7 @@ from .types import CreateUserRequestMember from .types import APIKey from .types import Application +from .types import GracePeriod from .types import Group from .types import Log from .types import PermissionSet @@ -60,6 +62,8 @@ from .types import ListAPIKeysResponse from .types import ListApplicationsRequest from .types import ListApplicationsResponse +from .types import ListGracePeriodsRequest +from .types import ListGracePeriodsResponse from .types import ListGroupsRequest from .types import ListGroupsResponse from .types import ListJWTsRequest @@ -95,6 +99,7 @@ __all__ = [ "BearerType", + "GracePeriodType", "ListAPIKeysRequestOrderBy", "ListApplicationsRequestOrderBy", "ListGroupsRequestOrderBy", @@ -115,6 +120,7 @@ "CreateUserRequestMember", "APIKey", "Application", + "GracePeriod", "Group", "Log", "PermissionSet", @@ -154,6 +160,8 @@ "ListAPIKeysResponse", "ListApplicationsRequest", "ListApplicationsResponse", + "ListGracePeriodsRequest", + "ListGracePeriodsResponse", "ListGroupsRequest", "ListGroupsResponse", "ListJWTsRequest", diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/api.py b/scaleway-async/scaleway_async/iam/v1alpha1/api.py index c5f053986..01646b907 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/api.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/api.py @@ -43,6 +43,7 @@ JWT, ListAPIKeysResponse, ListApplicationsResponse, + ListGracePeriodsResponse, ListGroupsResponse, ListJWTsResponse, ListLogsResponse, @@ -85,6 +86,7 @@ unmarshal_EncodedJWT, unmarshal_ListAPIKeysResponse, unmarshal_ListApplicationsResponse, + unmarshal_ListGracePeriodsResponse, unmarshal_ListGroupsResponse, unmarshal_ListJWTsResponse, unmarshal_ListLogsResponse, @@ -629,7 +631,7 @@ async def lock_user( """ Lock a user. Lock a user. Note that a locked user cannot log in or use API keys until the locked status is removed. - :param user_id: + :param user_id: ID of the user to lock. :return: :class:`User ` Usage: @@ -658,7 +660,7 @@ async def unlock_user( ) -> User: """ Unlock a user. - :param user_id: + :param user_id: ID of the user to unlock. :return: :class:`User ` Usage: @@ -680,6 +682,34 @@ async def unlock_user( self._throw_on_error(res) return unmarshal_User(res.json()) + async def list_grace_periods( + self, + *, + user_id: Optional[str] = None, + ) -> ListGracePeriodsResponse: + """ + List grace periods of a user. + List the grace periods of a user. + :param user_id: ID of the user to list grace periods for. + :return: :class:`ListGracePeriodsResponse ` + + Usage: + :: + + result = await api.list_grace_periods() + """ + + res = self._request( + "GET", + "/iam/v1alpha1/grace-periods", + params={ + "user_id": user_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListGracePeriodsResponse(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 3368c4103..bd5301e54 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py @@ -22,6 +22,8 @@ EncodedJWT, ListAPIKeysResponse, ListApplicationsResponse, + GracePeriod, + ListGracePeriodsResponse, ListGroupsResponse, ListJWTsResponse, ListLogsResponse, @@ -682,6 +684,50 @@ def unmarshal_ListApplicationsResponse(data: Any) -> ListApplicationsResponse: return ListApplicationsResponse(**args) +def unmarshal_GracePeriod(data: Any) -> GracePeriod: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GracePeriod' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + 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 GracePeriod(**args) + + +def unmarshal_ListGracePeriodsResponse(data: Any) -> ListGracePeriodsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListGracePeriodsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("grace_periods", None) + if field is not None: + args["grace_periods"] = ( + [unmarshal_GracePeriod(v) for v in field] if field is not None else None + ) + + return ListGracePeriodsResponse(**args) + + def unmarshal_ListGroupsResponse(data: Any) -> ListGroupsResponse: if not isinstance(data, dict): raise TypeError( diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/types.py b/scaleway-async/scaleway_async/iam/v1alpha1/types.py index 0527a528a..013dcf40e 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/types.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/types.py @@ -21,6 +21,15 @@ def __str__(self) -> str: return str(self.value) +class GracePeriodType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_GRACE_PERIOD_TYPE = "unknown_grace_period_type" + UPDATE_PASSWORD = "update_password" + SET_MFA = "set_mfa" + + def __str__(self) -> str: + return str(self.value) + + class ListAPIKeysRequestOrderBy(str, Enum, metaclass=StrEnumMeta): CREATED_AT_ASC = "created_at_asc" CREATED_AT_DESC = "created_at_desc" @@ -390,6 +399,24 @@ class Application: """ +@dataclass +class GracePeriod: + type_: GracePeriodType + """ + Type of grace period. + """ + + created_at: Optional[datetime] + """ + Date and time the grace period was created. + """ + + expires_at: Optional[datetime] + """ + Date and time the grace period expires. + """ + + @dataclass class Group: id: str @@ -1253,6 +1280,22 @@ class ListApplicationsResponse: """ +@dataclass +class ListGracePeriodsRequest: + user_id: Optional[str] + """ + ID of the user to list grace periods for. + """ + + +@dataclass +class ListGracePeriodsResponse: + grace_periods: List[GracePeriod] + """ + List of grace periods. + """ + + @dataclass class ListGroupsRequest: order_by: Optional[ListGroupsRequestOrderBy] @@ -1699,6 +1742,9 @@ class ListUsersResponse: @dataclass class LockUserRequest: user_id: str + """ + ID of the user to lock. + """ @dataclass @@ -1746,6 +1792,9 @@ class SetRulesResponse: @dataclass class UnlockUserRequest: user_id: str + """ + ID of the user to unlock. + """ @dataclass diff --git a/scaleway/scaleway/iam/v1alpha1/__init__.py b/scaleway/scaleway/iam/v1alpha1/__init__.py index bb4d8d674..a50d008a6 100644 --- a/scaleway/scaleway/iam/v1alpha1/__init__.py +++ b/scaleway/scaleway/iam/v1alpha1/__init__.py @@ -1,6 +1,7 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. from .types import BearerType +from .types import GracePeriodType from .types import ListAPIKeysRequestOrderBy from .types import ListApplicationsRequestOrderBy from .types import ListGroupsRequestOrderBy @@ -21,6 +22,7 @@ from .types import CreateUserRequestMember from .types import APIKey from .types import Application +from .types import GracePeriod from .types import Group from .types import Log from .types import PermissionSet @@ -60,6 +62,8 @@ from .types import ListAPIKeysResponse from .types import ListApplicationsRequest from .types import ListApplicationsResponse +from .types import ListGracePeriodsRequest +from .types import ListGracePeriodsResponse from .types import ListGroupsRequest from .types import ListGroupsResponse from .types import ListJWTsRequest @@ -95,6 +99,7 @@ __all__ = [ "BearerType", + "GracePeriodType", "ListAPIKeysRequestOrderBy", "ListApplicationsRequestOrderBy", "ListGroupsRequestOrderBy", @@ -115,6 +120,7 @@ "CreateUserRequestMember", "APIKey", "Application", + "GracePeriod", "Group", "Log", "PermissionSet", @@ -154,6 +160,8 @@ "ListAPIKeysResponse", "ListApplicationsRequest", "ListApplicationsResponse", + "ListGracePeriodsRequest", + "ListGracePeriodsResponse", "ListGroupsRequest", "ListGroupsResponse", "ListJWTsRequest", diff --git a/scaleway/scaleway/iam/v1alpha1/api.py b/scaleway/scaleway/iam/v1alpha1/api.py index 987308e77..914208e89 100644 --- a/scaleway/scaleway/iam/v1alpha1/api.py +++ b/scaleway/scaleway/iam/v1alpha1/api.py @@ -43,6 +43,7 @@ JWT, ListAPIKeysResponse, ListApplicationsResponse, + ListGracePeriodsResponse, ListGroupsResponse, ListJWTsResponse, ListLogsResponse, @@ -85,6 +86,7 @@ unmarshal_EncodedJWT, unmarshal_ListAPIKeysResponse, unmarshal_ListApplicationsResponse, + unmarshal_ListGracePeriodsResponse, unmarshal_ListGroupsResponse, unmarshal_ListJWTsResponse, unmarshal_ListLogsResponse, @@ -629,7 +631,7 @@ def lock_user( """ Lock a user. Lock a user. Note that a locked user cannot log in or use API keys until the locked status is removed. - :param user_id: + :param user_id: ID of the user to lock. :return: :class:`User ` Usage: @@ -658,7 +660,7 @@ def unlock_user( ) -> User: """ Unlock a user. - :param user_id: + :param user_id: ID of the user to unlock. :return: :class:`User ` Usage: @@ -680,6 +682,34 @@ def unlock_user( self._throw_on_error(res) return unmarshal_User(res.json()) + def list_grace_periods( + self, + *, + user_id: Optional[str] = None, + ) -> ListGracePeriodsResponse: + """ + List grace periods of a user. + List the grace periods of a user. + :param user_id: ID of the user to list grace periods for. + :return: :class:`ListGracePeriodsResponse ` + + Usage: + :: + + result = api.list_grace_periods() + """ + + res = self._request( + "GET", + "/iam/v1alpha1/grace-periods", + params={ + "user_id": user_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListGracePeriodsResponse(res.json()) + def list_applications( self, *, diff --git a/scaleway/scaleway/iam/v1alpha1/marshalling.py b/scaleway/scaleway/iam/v1alpha1/marshalling.py index 3368c4103..bd5301e54 100644 --- a/scaleway/scaleway/iam/v1alpha1/marshalling.py +++ b/scaleway/scaleway/iam/v1alpha1/marshalling.py @@ -22,6 +22,8 @@ EncodedJWT, ListAPIKeysResponse, ListApplicationsResponse, + GracePeriod, + ListGracePeriodsResponse, ListGroupsResponse, ListJWTsResponse, ListLogsResponse, @@ -682,6 +684,50 @@ def unmarshal_ListApplicationsResponse(data: Any) -> ListApplicationsResponse: return ListApplicationsResponse(**args) +def unmarshal_GracePeriod(data: Any) -> GracePeriod: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GracePeriod' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + 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 GracePeriod(**args) + + +def unmarshal_ListGracePeriodsResponse(data: Any) -> ListGracePeriodsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListGracePeriodsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("grace_periods", None) + if field is not None: + args["grace_periods"] = ( + [unmarshal_GracePeriod(v) for v in field] if field is not None else None + ) + + return ListGracePeriodsResponse(**args) + + def unmarshal_ListGroupsResponse(data: Any) -> ListGroupsResponse: if not isinstance(data, dict): raise TypeError( diff --git a/scaleway/scaleway/iam/v1alpha1/types.py b/scaleway/scaleway/iam/v1alpha1/types.py index 0527a528a..013dcf40e 100644 --- a/scaleway/scaleway/iam/v1alpha1/types.py +++ b/scaleway/scaleway/iam/v1alpha1/types.py @@ -21,6 +21,15 @@ def __str__(self) -> str: return str(self.value) +class GracePeriodType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_GRACE_PERIOD_TYPE = "unknown_grace_period_type" + UPDATE_PASSWORD = "update_password" + SET_MFA = "set_mfa" + + def __str__(self) -> str: + return str(self.value) + + class ListAPIKeysRequestOrderBy(str, Enum, metaclass=StrEnumMeta): CREATED_AT_ASC = "created_at_asc" CREATED_AT_DESC = "created_at_desc" @@ -390,6 +399,24 @@ class Application: """ +@dataclass +class GracePeriod: + type_: GracePeriodType + """ + Type of grace period. + """ + + created_at: Optional[datetime] + """ + Date and time the grace period was created. + """ + + expires_at: Optional[datetime] + """ + Date and time the grace period expires. + """ + + @dataclass class Group: id: str @@ -1253,6 +1280,22 @@ class ListApplicationsResponse: """ +@dataclass +class ListGracePeriodsRequest: + user_id: Optional[str] + """ + ID of the user to list grace periods for. + """ + + +@dataclass +class ListGracePeriodsResponse: + grace_periods: List[GracePeriod] + """ + List of grace periods. + """ + + @dataclass class ListGroupsRequest: order_by: Optional[ListGroupsRequestOrderBy] @@ -1699,6 +1742,9 @@ class ListUsersResponse: @dataclass class LockUserRequest: user_id: str + """ + ID of the user to lock. + """ @dataclass @@ -1746,6 +1792,9 @@ class SetRulesResponse: @dataclass class UnlockUserRequest: user_id: str + """ + ID of the user to unlock. + """ @dataclass