Skip to content

Commit d295c44

Browse files
authored
feat(iam): add list user grace periods method (#759)
1 parent 8c65b55 commit d295c44

File tree

8 files changed

+270
-4
lines changed

8 files changed

+270
-4
lines changed

scaleway-async/scaleway_async/iam/v1alpha1/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This file was automatically generated. DO NOT EDIT.
22
# If you have any remark or suggestion do not hesitate to open an issue.
33
from .types import BearerType
4+
from .types import GracePeriodType
45
from .types import ListAPIKeysRequestOrderBy
56
from .types import ListApplicationsRequestOrderBy
67
from .types import ListGroupsRequestOrderBy
@@ -21,6 +22,7 @@
2122
from .types import CreateUserRequestMember
2223
from .types import APIKey
2324
from .types import Application
25+
from .types import GracePeriod
2426
from .types import Group
2527
from .types import Log
2628
from .types import PermissionSet
@@ -60,6 +62,8 @@
6062
from .types import ListAPIKeysResponse
6163
from .types import ListApplicationsRequest
6264
from .types import ListApplicationsResponse
65+
from .types import ListGracePeriodsRequest
66+
from .types import ListGracePeriodsResponse
6367
from .types import ListGroupsRequest
6468
from .types import ListGroupsResponse
6569
from .types import ListJWTsRequest
@@ -95,6 +99,7 @@
9599

96100
__all__ = [
97101
"BearerType",
102+
"GracePeriodType",
98103
"ListAPIKeysRequestOrderBy",
99104
"ListApplicationsRequestOrderBy",
100105
"ListGroupsRequestOrderBy",
@@ -115,6 +120,7 @@
115120
"CreateUserRequestMember",
116121
"APIKey",
117122
"Application",
123+
"GracePeriod",
118124
"Group",
119125
"Log",
120126
"PermissionSet",
@@ -154,6 +160,8 @@
154160
"ListAPIKeysResponse",
155161
"ListApplicationsRequest",
156162
"ListApplicationsResponse",
163+
"ListGracePeriodsRequest",
164+
"ListGracePeriodsResponse",
157165
"ListGroupsRequest",
158166
"ListGroupsResponse",
159167
"ListJWTsRequest",

scaleway-async/scaleway_async/iam/v1alpha1/api.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
JWT,
4444
ListAPIKeysResponse,
4545
ListApplicationsResponse,
46+
ListGracePeriodsResponse,
4647
ListGroupsResponse,
4748
ListJWTsResponse,
4849
ListLogsResponse,
@@ -85,6 +86,7 @@
8586
unmarshal_EncodedJWT,
8687
unmarshal_ListAPIKeysResponse,
8788
unmarshal_ListApplicationsResponse,
89+
unmarshal_ListGracePeriodsResponse,
8890
unmarshal_ListGroupsResponse,
8991
unmarshal_ListJWTsResponse,
9092
unmarshal_ListLogsResponse,
@@ -629,7 +631,7 @@ async def lock_user(
629631
"""
630632
Lock a user.
631633
Lock a user. Note that a locked user cannot log in or use API keys until the locked status is removed.
632-
:param user_id:
634+
:param user_id: ID of the user to lock.
633635
:return: :class:`User <User>`
634636
635637
Usage:
@@ -658,7 +660,7 @@ async def unlock_user(
658660
) -> User:
659661
"""
660662
Unlock a user.
661-
:param user_id:
663+
:param user_id: ID of the user to unlock.
662664
:return: :class:`User <User>`
663665
664666
Usage:
@@ -680,6 +682,34 @@ async def unlock_user(
680682
self._throw_on_error(res)
681683
return unmarshal_User(res.json())
682684

685+
async def list_grace_periods(
686+
self,
687+
*,
688+
user_id: Optional[str] = None,
689+
) -> ListGracePeriodsResponse:
690+
"""
691+
List grace periods of a user.
692+
List the grace periods of a user.
693+
:param user_id: ID of the user to list grace periods for.
694+
:return: :class:`ListGracePeriodsResponse <ListGracePeriodsResponse>`
695+
696+
Usage:
697+
::
698+
699+
result = await api.list_grace_periods()
700+
"""
701+
702+
res = self._request(
703+
"GET",
704+
"/iam/v1alpha1/grace-periods",
705+
params={
706+
"user_id": user_id,
707+
},
708+
)
709+
710+
self._throw_on_error(res)
711+
return unmarshal_ListGracePeriodsResponse(res.json())
712+
683713
async def list_applications(
684714
self,
685715
*,

scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
EncodedJWT,
2323
ListAPIKeysResponse,
2424
ListApplicationsResponse,
25+
GracePeriod,
26+
ListGracePeriodsResponse,
2527
ListGroupsResponse,
2628
ListJWTsResponse,
2729
ListLogsResponse,
@@ -682,6 +684,50 @@ def unmarshal_ListApplicationsResponse(data: Any) -> ListApplicationsResponse:
682684
return ListApplicationsResponse(**args)
683685

684686

687+
def unmarshal_GracePeriod(data: Any) -> GracePeriod:
688+
if not isinstance(data, dict):
689+
raise TypeError(
690+
"Unmarshalling the type 'GracePeriod' failed as data isn't a dictionary."
691+
)
692+
693+
args: Dict[str, Any] = {}
694+
695+
field = data.get("type", None)
696+
if field is not None:
697+
args["type_"] = field
698+
699+
field = data.get("created_at", None)
700+
if field is not None:
701+
args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field
702+
else:
703+
args["created_at"] = None
704+
705+
field = data.get("expires_at", None)
706+
if field is not None:
707+
args["expires_at"] = parser.isoparse(field) if isinstance(field, str) else field
708+
else:
709+
args["expires_at"] = None
710+
711+
return GracePeriod(**args)
712+
713+
714+
def unmarshal_ListGracePeriodsResponse(data: Any) -> ListGracePeriodsResponse:
715+
if not isinstance(data, dict):
716+
raise TypeError(
717+
"Unmarshalling the type 'ListGracePeriodsResponse' failed as data isn't a dictionary."
718+
)
719+
720+
args: Dict[str, Any] = {}
721+
722+
field = data.get("grace_periods", None)
723+
if field is not None:
724+
args["grace_periods"] = (
725+
[unmarshal_GracePeriod(v) for v in field] if field is not None else None
726+
)
727+
728+
return ListGracePeriodsResponse(**args)
729+
730+
685731
def unmarshal_ListGroupsResponse(data: Any) -> ListGroupsResponse:
686732
if not isinstance(data, dict):
687733
raise TypeError(

scaleway-async/scaleway_async/iam/v1alpha1/types.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ def __str__(self) -> str:
2121
return str(self.value)
2222

2323

24+
class GracePeriodType(str, Enum, metaclass=StrEnumMeta):
25+
UNKNOWN_GRACE_PERIOD_TYPE = "unknown_grace_period_type"
26+
UPDATE_PASSWORD = "update_password"
27+
SET_MFA = "set_mfa"
28+
29+
def __str__(self) -> str:
30+
return str(self.value)
31+
32+
2433
class ListAPIKeysRequestOrderBy(str, Enum, metaclass=StrEnumMeta):
2534
CREATED_AT_ASC = "created_at_asc"
2635
CREATED_AT_DESC = "created_at_desc"
@@ -390,6 +399,24 @@ class Application:
390399
"""
391400

392401

402+
@dataclass
403+
class GracePeriod:
404+
type_: GracePeriodType
405+
"""
406+
Type of grace period.
407+
"""
408+
409+
created_at: Optional[datetime]
410+
"""
411+
Date and time the grace period was created.
412+
"""
413+
414+
expires_at: Optional[datetime]
415+
"""
416+
Date and time the grace period expires.
417+
"""
418+
419+
393420
@dataclass
394421
class Group:
395422
id: str
@@ -1253,6 +1280,22 @@ class ListApplicationsResponse:
12531280
"""
12541281

12551282

1283+
@dataclass
1284+
class ListGracePeriodsRequest:
1285+
user_id: Optional[str]
1286+
"""
1287+
ID of the user to list grace periods for.
1288+
"""
1289+
1290+
1291+
@dataclass
1292+
class ListGracePeriodsResponse:
1293+
grace_periods: List[GracePeriod]
1294+
"""
1295+
List of grace periods.
1296+
"""
1297+
1298+
12561299
@dataclass
12571300
class ListGroupsRequest:
12581301
order_by: Optional[ListGroupsRequestOrderBy]
@@ -1699,6 +1742,9 @@ class ListUsersResponse:
16991742
@dataclass
17001743
class LockUserRequest:
17011744
user_id: str
1745+
"""
1746+
ID of the user to lock.
1747+
"""
17021748

17031749

17041750
@dataclass
@@ -1746,6 +1792,9 @@ class SetRulesResponse:
17461792
@dataclass
17471793
class UnlockUserRequest:
17481794
user_id: str
1795+
"""
1796+
ID of the user to unlock.
1797+
"""
17491798

17501799

17511800
@dataclass

scaleway/scaleway/iam/v1alpha1/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This file was automatically generated. DO NOT EDIT.
22
# If you have any remark or suggestion do not hesitate to open an issue.
33
from .types import BearerType
4+
from .types import GracePeriodType
45
from .types import ListAPIKeysRequestOrderBy
56
from .types import ListApplicationsRequestOrderBy
67
from .types import ListGroupsRequestOrderBy
@@ -21,6 +22,7 @@
2122
from .types import CreateUserRequestMember
2223
from .types import APIKey
2324
from .types import Application
25+
from .types import GracePeriod
2426
from .types import Group
2527
from .types import Log
2628
from .types import PermissionSet
@@ -60,6 +62,8 @@
6062
from .types import ListAPIKeysResponse
6163
from .types import ListApplicationsRequest
6264
from .types import ListApplicationsResponse
65+
from .types import ListGracePeriodsRequest
66+
from .types import ListGracePeriodsResponse
6367
from .types import ListGroupsRequest
6468
from .types import ListGroupsResponse
6569
from .types import ListJWTsRequest
@@ -95,6 +99,7 @@
9599

96100
__all__ = [
97101
"BearerType",
102+
"GracePeriodType",
98103
"ListAPIKeysRequestOrderBy",
99104
"ListApplicationsRequestOrderBy",
100105
"ListGroupsRequestOrderBy",
@@ -115,6 +120,7 @@
115120
"CreateUserRequestMember",
116121
"APIKey",
117122
"Application",
123+
"GracePeriod",
118124
"Group",
119125
"Log",
120126
"PermissionSet",
@@ -154,6 +160,8 @@
154160
"ListAPIKeysResponse",
155161
"ListApplicationsRequest",
156162
"ListApplicationsResponse",
163+
"ListGracePeriodsRequest",
164+
"ListGracePeriodsResponse",
157165
"ListGroupsRequest",
158166
"ListGroupsResponse",
159167
"ListJWTsRequest",

scaleway/scaleway/iam/v1alpha1/api.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
JWT,
4444
ListAPIKeysResponse,
4545
ListApplicationsResponse,
46+
ListGracePeriodsResponse,
4647
ListGroupsResponse,
4748
ListJWTsResponse,
4849
ListLogsResponse,
@@ -85,6 +86,7 @@
8586
unmarshal_EncodedJWT,
8687
unmarshal_ListAPIKeysResponse,
8788
unmarshal_ListApplicationsResponse,
89+
unmarshal_ListGracePeriodsResponse,
8890
unmarshal_ListGroupsResponse,
8991
unmarshal_ListJWTsResponse,
9092
unmarshal_ListLogsResponse,
@@ -629,7 +631,7 @@ def lock_user(
629631
"""
630632
Lock a user.
631633
Lock a user. Note that a locked user cannot log in or use API keys until the locked status is removed.
632-
:param user_id:
634+
:param user_id: ID of the user to lock.
633635
:return: :class:`User <User>`
634636
635637
Usage:
@@ -658,7 +660,7 @@ def unlock_user(
658660
) -> User:
659661
"""
660662
Unlock a user.
661-
:param user_id:
663+
:param user_id: ID of the user to unlock.
662664
:return: :class:`User <User>`
663665
664666
Usage:
@@ -680,6 +682,34 @@ def unlock_user(
680682
self._throw_on_error(res)
681683
return unmarshal_User(res.json())
682684

685+
def list_grace_periods(
686+
self,
687+
*,
688+
user_id: Optional[str] = None,
689+
) -> ListGracePeriodsResponse:
690+
"""
691+
List grace periods of a user.
692+
List the grace periods of a user.
693+
:param user_id: ID of the user to list grace periods for.
694+
:return: :class:`ListGracePeriodsResponse <ListGracePeriodsResponse>`
695+
696+
Usage:
697+
::
698+
699+
result = api.list_grace_periods()
700+
"""
701+
702+
res = self._request(
703+
"GET",
704+
"/iam/v1alpha1/grace-periods",
705+
params={
706+
"user_id": user_id,
707+
},
708+
)
709+
710+
self._throw_on_error(res)
711+
return unmarshal_ListGracePeriodsResponse(res.json())
712+
683713
def list_applications(
684714
self,
685715
*,

0 commit comments

Comments
 (0)