Skip to content

Commit 32f1a24

Browse files
authored
feat(iam): add tags on applications, groups, users and policies (#373)
1 parent 9180d7e commit 32f1a24

File tree

6 files changed

+306
-0
lines changed

6 files changed

+306
-0
lines changed

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ async def list_users(
344344
organization_id: Optional[str] = None,
345345
user_ids: Optional[List[str]] = None,
346346
mfa: Optional[bool] = None,
347+
tag: Optional[str] = None,
347348
) -> ListUsersResponse:
348349
"""
349350
List users of an Organization.
@@ -354,6 +355,7 @@ async def list_users(
354355
:param organization_id: ID of the Organization to filter.
355356
:param user_ids: Filter by list of IDs.
356357
:param mfa: Filter by MFA status.
358+
:param tag: Filter by tags containing a given string.
357359
:return: :class:`ListUsersResponse <ListUsersResponse>`
358360
359361
Usage:
@@ -372,6 +374,7 @@ async def list_users(
372374
or self.client.default_organization_id,
373375
"page": page,
374376
"page_size": page_size or self.client.default_page_size,
377+
"tag": tag,
375378
"user_ids": user_ids,
376379
},
377380
)
@@ -388,6 +391,7 @@ async def list_users_all(
388391
organization_id: Optional[str] = None,
389392
user_ids: Optional[List[str]] = None,
390393
mfa: Optional[bool] = None,
394+
tag: Optional[str] = None,
391395
) -> List[User]:
392396
"""
393397
List users of an Organization.
@@ -398,6 +402,7 @@ async def list_users_all(
398402
:param organization_id: ID of the Organization to filter.
399403
:param user_ids: Filter by list of IDs.
400404
:param mfa: Filter by MFA status.
405+
:param tag: Filter by tags containing a given string.
401406
:return: :class:`List[ListUsersResponse] <List[ListUsersResponse]>`
402407
403408
Usage:
@@ -417,6 +422,7 @@ async def list_users_all(
417422
"organization_id": organization_id,
418423
"user_ids": user_ids,
419424
"mfa": mfa,
425+
"tag": tag,
420426
},
421427
)
422428

@@ -478,12 +484,14 @@ async def create_user(
478484
*,
479485
email: str,
480486
organization_id: Optional[str] = None,
487+
tags: Optional[List[str]] = None,
481488
) -> User:
482489
"""
483490
Create a new user.
484491
Create a new user. You must define the `organization_id` and the `email` in your request.
485492
:param organization_id: ID of the Organization.
486493
:param email: Email of the user.
494+
:param tags: Tags associated with the user.
487495
:return: :class:`User <User>`
488496
489497
Usage:
@@ -499,6 +507,7 @@ async def create_user(
499507
CreateUserRequest(
500508
email=email,
501509
organization_id=organization_id,
510+
tags=tags,
502511
),
503512
self.client,
504513
),
@@ -517,6 +526,7 @@ async def list_applications(
517526
organization_id: Optional[str] = None,
518527
editable: Optional[bool] = None,
519528
application_ids: Optional[List[str]] = None,
529+
tag: Optional[str] = None,
520530
) -> ListApplicationsResponse:
521531
"""
522532
List applications of an Organization.
@@ -528,6 +538,7 @@ async def list_applications(
528538
:param organization_id: ID of the Organization to filter.
529539
:param editable: Defines whether to filter out editable applications or not.
530540
:param application_ids: Filter by list of IDs.
541+
:param tag: Filter by tags containing a given string.
531542
:return: :class:`ListApplicationsResponse <ListApplicationsResponse>`
532543
533544
Usage:
@@ -548,6 +559,7 @@ async def list_applications(
548559
or self.client.default_organization_id,
549560
"page": page,
550561
"page_size": page_size or self.client.default_page_size,
562+
"tag": tag,
551563
},
552564
)
553565

@@ -564,6 +576,7 @@ async def list_applications_all(
564576
organization_id: Optional[str] = None,
565577
editable: Optional[bool] = None,
566578
application_ids: Optional[List[str]] = None,
579+
tag: Optional[str] = None,
567580
) -> List[Application]:
568581
"""
569582
List applications of an Organization.
@@ -575,6 +588,7 @@ async def list_applications_all(
575588
:param organization_id: ID of the Organization to filter.
576589
:param editable: Defines whether to filter out editable applications or not.
577590
:param application_ids: Filter by list of IDs.
591+
:param tag: Filter by tags containing a given string.
578592
:return: :class:`List[ListApplicationsResponse] <List[ListApplicationsResponse]>`
579593
580594
Usage:
@@ -595,6 +609,7 @@ async def list_applications_all(
595609
"organization_id": organization_id,
596610
"editable": editable,
597611
"application_ids": application_ids,
612+
"tag": tag,
598613
},
599614
)
600615

@@ -604,13 +619,15 @@ async def create_application(
604619
description: str,
605620
name: Optional[str] = None,
606621
organization_id: Optional[str] = None,
622+
tags: Optional[List[str]] = None,
607623
) -> Application:
608624
"""
609625
Create a new application.
610626
Create a new application. You must define the `name` parameter in the request.
611627
:param name: Name of the application to create (max length is 64 characters).
612628
:param organization_id: ID of the Organization.
613629
:param description: Description of the application (max length is 200 characters).
630+
:param tags: Tags associated with the application (maximum of 10 tags).
614631
:return: :class:`Application <Application>`
615632
616633
Usage:
@@ -627,6 +644,7 @@ async def create_application(
627644
description=description,
628645
name=name or random_name(prefix="app"),
629646
organization_id=organization_id,
647+
tags=tags,
630648
),
631649
self.client,
632650
),
@@ -668,13 +686,15 @@ async def update_application(
668686
application_id: str,
669687
name: Optional[str] = None,
670688
description: Optional[str] = None,
689+
tags: Optional[List[str]] = None,
671690
) -> Application:
672691
"""
673692
Update an application.
674693
Update the parameters of an application, including `name` and `description`.
675694
:param application_id: ID of the application to update.
676695
:param name: New name for the application (max length is 64 chars).
677696
:param description: New description for the application (max length is 200 chars).
697+
:param tags: New tags for the application (maximum of 10 tags).
678698
:return: :class:`Application <Application>`
679699
680700
Usage:
@@ -693,6 +713,7 @@ async def update_application(
693713
application_id=application_id,
694714
name=name,
695715
description=description,
716+
tags=tags,
696717
),
697718
self.client,
698719
),
@@ -738,6 +759,7 @@ async def list_groups(
738759
application_ids: Optional[List[str]] = None,
739760
user_ids: Optional[List[str]] = None,
740761
group_ids: Optional[List[str]] = None,
762+
tag: Optional[str] = None,
741763
) -> ListGroupsResponse:
742764
"""
743765
List groups.
@@ -750,6 +772,7 @@ async def list_groups(
750772
:param application_ids: Filter by a list of application IDs.
751773
:param user_ids: Filter by a list of user IDs.
752774
:param group_ids: Filter by a list of group IDs.
775+
:param tag: Filter by tags containing a given string.
753776
:return: :class:`ListGroupsResponse <ListGroupsResponse>`
754777
755778
Usage:
@@ -770,6 +793,7 @@ async def list_groups(
770793
or self.client.default_organization_id,
771794
"page": page,
772795
"page_size": page_size or self.client.default_page_size,
796+
"tag": tag,
773797
"user_ids": user_ids,
774798
},
775799
)
@@ -788,6 +812,7 @@ async def list_groups_all(
788812
application_ids: Optional[List[str]] = None,
789813
user_ids: Optional[List[str]] = None,
790814
group_ids: Optional[List[str]] = None,
815+
tag: Optional[str] = None,
791816
) -> List[Group]:
792817
"""
793818
List groups.
@@ -800,6 +825,7 @@ async def list_groups_all(
800825
:param application_ids: Filter by a list of application IDs.
801826
:param user_ids: Filter by a list of user IDs.
802827
:param group_ids: Filter by a list of group IDs.
828+
:param tag: Filter by tags containing a given string.
803829
:return: :class:`List[ListGroupsResponse] <List[ListGroupsResponse]>`
804830
805831
Usage:
@@ -821,6 +847,7 @@ async def list_groups_all(
821847
"application_ids": application_ids,
822848
"user_ids": user_ids,
823849
"group_ids": group_ids,
850+
"tag": tag,
824851
},
825852
)
826853

@@ -830,13 +857,15 @@ async def create_group(
830857
description: str,
831858
organization_id: Optional[str] = None,
832859
name: Optional[str] = None,
860+
tags: Optional[List[str]] = None,
833861
) -> Group:
834862
"""
835863
Create a group.
836864
Create a new group. You must define the `name` and `organization_id` parameters in the request.
837865
:param organization_id: ID of Organization linked to the group.
838866
:param name: Name of the group to create (max length is 64 chars). MUST be unique inside an Organization.
839867
:param description: Description of the group to create (max length is 200 chars).
868+
:param tags: Tags associated with the group (maximum of 10 tags).
840869
:return: :class:`Group <Group>`
841870
842871
Usage:
@@ -853,6 +882,7 @@ async def create_group(
853882
description=description,
854883
organization_id=organization_id,
855884
name=name or random_name(prefix="grp"),
885+
tags=tags,
856886
),
857887
self.client,
858888
),
@@ -894,13 +924,15 @@ async def update_group(
894924
group_id: str,
895925
name: Optional[str] = None,
896926
description: Optional[str] = None,
927+
tags: Optional[List[str]] = None,
897928
) -> Group:
898929
"""
899930
Update a group.
900931
Update the parameters of group, including `name` and `description`.
901932
:param group_id: ID of the group to update.
902933
:param name: New name for the group (max length is 64 chars). MUST be unique inside an Organization.
903934
:param description: New description for the group (max length is 200 chars).
935+
:param tags: New tags for the group (maximum of 10 tags).
904936
:return: :class:`Group <Group>`
905937
906938
Usage:
@@ -919,6 +951,7 @@ async def update_group(
919951
group_id=group_id,
920952
name=name,
921953
description=description,
954+
tags=tags,
922955
),
923956
self.client,
924957
),
@@ -1134,6 +1167,7 @@ async def list_policies(
11341167
application_ids: Optional[List[str]] = None,
11351168
no_principal: Optional[bool] = None,
11361169
policy_name: Optional[str] = None,
1170+
tag: Optional[str] = None,
11371171
) -> ListPoliciesResponse:
11381172
"""
11391173
List policies of an Organization.
@@ -1148,6 +1182,7 @@ async def list_policies(
11481182
:param application_ids: Filter by a list of application IDs.
11491183
:param no_principal: Defines whether or not the policy is attributed to a principal.
11501184
:param policy_name: Name of the policy to fetch.
1185+
:param tag: Filter by tags containing a given string.
11511186
:return: :class:`ListPoliciesResponse <ListPoliciesResponse>`
11521187
11531188
Usage:
@@ -1170,6 +1205,7 @@ async def list_policies(
11701205
"page": page,
11711206
"page_size": page_size or self.client.default_page_size,
11721207
"policy_name": policy_name,
1208+
"tag": tag,
11731209
"user_ids": user_ids,
11741210
},
11751211
)
@@ -1190,6 +1226,7 @@ async def list_policies_all(
11901226
application_ids: Optional[List[str]] = None,
11911227
no_principal: Optional[bool] = None,
11921228
policy_name: Optional[str] = None,
1229+
tag: Optional[str] = None,
11931230
) -> List[Policy]:
11941231
"""
11951232
List policies of an Organization.
@@ -1204,6 +1241,7 @@ async def list_policies_all(
12041241
:param application_ids: Filter by a list of application IDs.
12051242
:param no_principal: Defines whether or not the policy is attributed to a principal.
12061243
:param policy_name: Name of the policy to fetch.
1244+
:param tag: Filter by tags containing a given string.
12071245
:return: :class:`List[ListPoliciesResponse] <List[ListPoliciesResponse]>`
12081246
12091247
Usage:
@@ -1227,6 +1265,7 @@ async def list_policies_all(
12271265
"application_ids": application_ids,
12281266
"no_principal": no_principal,
12291267
"policy_name": policy_name,
1268+
"tag": tag,
12301269
},
12311270
)
12321271

@@ -1237,6 +1276,7 @@ async def create_policy(
12371276
name: Optional[str] = None,
12381277
organization_id: Optional[str] = None,
12391278
rules: Optional[List[RuleSpecs]] = None,
1279+
tags: Optional[List[str]] = None,
12401280
user_id: Optional[str] = None,
12411281
group_id: Optional[str] = None,
12421282
application_id: Optional[str] = None,
@@ -1249,6 +1289,7 @@ async def create_policy(
12491289
:param description: Description of the policy to create (max length is 200 characters).
12501290
:param organization_id: ID of the Organization.
12511291
:param rules: Rules of the policy to create.
1292+
:param tags: Tags associated with the policy (maximum of 10 tags).
12521293
:param user_id: ID of user attributed to the policy.
12531294
12541295
One-of ('principal'): at most one of 'user_id', 'group_id', 'application_id', 'no_principal' could be set.
@@ -1278,6 +1319,7 @@ async def create_policy(
12781319
name=name or random_name(prefix="pol"),
12791320
organization_id=organization_id,
12801321
rules=rules,
1322+
tags=tags,
12811323
user_id=user_id,
12821324
group_id=group_id,
12831325
application_id=application_id,
@@ -1323,6 +1365,7 @@ async def update_policy(
13231365
policy_id: str,
13241366
name: Optional[str] = None,
13251367
description: Optional[str] = None,
1368+
tags: Optional[List[str]] = None,
13261369
user_id: Optional[str] = None,
13271370
group_id: Optional[str] = None,
13281371
application_id: Optional[str] = None,
@@ -1334,6 +1377,7 @@ async def update_policy(
13341377
:param policy_id: Id of policy to update.
13351378
:param name: New name for the policy (max length is 64 characters).
13361379
:param description: New description of policy (max length is 200 characters).
1380+
:param tags: New tags for the policy (maximum of 10 tags).
13371381
:param user_id: New ID of user attributed to the policy.
13381382
13391383
One-of ('principal'): at most one of 'user_id', 'group_id', 'application_id', 'no_principal' could be set.
@@ -1364,6 +1408,7 @@ async def update_policy(
13641408
policy_id=policy_id,
13651409
name=name,
13661410
description=description,
1411+
tags=tags,
13671412
user_id=user_id,
13681413
group_id=group_id,
13691414
application_id=application_id,

0 commit comments

Comments
 (0)