Skip to content

Commit d9126cd

Browse files
nejchJohnVillalovos
authored andcommitted
fix: support array types for most resources
1 parent 005ba93 commit d9126cd

13 files changed

+61
-14
lines changed

gitlab/v4/objects/broadcast_messages.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from gitlab.base import RESTManager, RESTObject
44
from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin
5-
from gitlab.types import RequiredOptional
5+
from gitlab.types import ArrayAttribute, RequiredOptional
66

77
__all__ = [
88
"BroadcastMessage",
@@ -19,11 +19,20 @@ class BroadcastMessageManager(CRUDMixin, RESTManager):
1919
_obj_cls = BroadcastMessage
2020

2121
_create_attrs = RequiredOptional(
22-
required=("message",), optional=("starts_at", "ends_at", "color", "font")
22+
required=("message",),
23+
optional=("starts_at", "ends_at", "color", "font", "target_access_levels"),
2324
)
2425
_update_attrs = RequiredOptional(
25-
optional=("message", "starts_at", "ends_at", "color", "font")
26+
optional=(
27+
"message",
28+
"starts_at",
29+
"ends_at",
30+
"color",
31+
"font",
32+
"target_access_levels",
33+
)
2634
)
35+
_types = {"target_access_levels": ArrayAttribute}
2736

2837
def get(
2938
self, id: Union[str, int], lazy: bool = False, **kwargs: Any

gitlab/v4/objects/deploy_tokens.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class GroupDeployTokenManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManag
4848
"username",
4949
),
5050
)
51-
_types = {"scopes": types.CommaSeparatedListAttribute}
51+
_list_filters = ("scopes",)
52+
_types = {"scopes": types.ArrayAttribute}
5253

5354
def get(
5455
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
@@ -74,7 +75,8 @@ class ProjectDeployTokenManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTMan
7475
"username",
7576
),
7677
)
77-
_types = {"scopes": types.CommaSeparatedListAttribute}
78+
_list_filters = ("scopes",)
79+
_types = {"scopes": types.ArrayAttribute}
7880

7981
def get(
8082
self, id: Union[str, int], lazy: bool = False, **kwargs: Any

gitlab/v4/objects/environments.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
SaveMixin,
1414
UpdateMixin,
1515
)
16-
from gitlab.types import RequiredOptional
16+
from gitlab.types import ArrayAttribute, RequiredOptional
1717

1818
__all__ = [
1919
"ProjectEnvironment",
@@ -77,6 +77,7 @@ class ProjectProtectedEnvironmentManager(
7777
),
7878
optional=("required_approval_count", "approval_rules"),
7979
)
80+
_types = {"deploy_access_levels": ArrayAttribute, "approval_rules": ArrayAttribute}
8081

8182
def get(
8283
self, id: Union[str, int], lazy: bool = False, **kwargs: Any

gitlab/v4/objects/group_access_tokens.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from gitlab.base import RESTManager, RESTObject
22
from gitlab.mixins import CreateMixin, DeleteMixin, ListMixin, ObjectDeleteMixin
3+
from gitlab.types import ArrayAttribute, RequiredOptional
34

45
__all__ = [
56
"GroupAccessToken",
@@ -15,3 +16,7 @@ class GroupAccessTokenManager(ListMixin, CreateMixin, DeleteMixin, RESTManager):
1516
_path = "/groups/{group_id}/access_tokens"
1617
_obj_cls = GroupAccessToken
1718
_from_parent_attrs = {"group_id": "id"}
19+
_create_attrs = RequiredOptional(
20+
required=("name", "scopes"), optional=("access_level", "expires_at")
21+
)
22+
_types = {"scopes": ArrayAttribute}

gitlab/v4/objects/invitations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from gitlab.base import RESTManager, RESTObject
44
from gitlab.exceptions import GitlabInvitationError
55
from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin
6-
from gitlab.types import CommaSeparatedListAttribute, RequiredOptional
6+
from gitlab.types import ArrayAttribute, CommaSeparatedListAttribute, RequiredOptional
77

88
__all__ = [
99
"ProjectInvitation",
@@ -48,6 +48,7 @@ class ProjectInvitationManager(InvitationMixin, RESTManager):
4848
_types = {
4949
"email": CommaSeparatedListAttribute,
5050
"user_id": CommaSeparatedListAttribute,
51+
"tasks_to_be_done": ArrayAttribute,
5152
}
5253

5354
def get(
@@ -81,6 +82,7 @@ class GroupInvitationManager(InvitationMixin, RESTManager):
8182
_types = {
8283
"email": CommaSeparatedListAttribute,
8384
"user_id": CommaSeparatedListAttribute,
85+
"tasks_to_be_done": ArrayAttribute,
8486
}
8587

8688
def get(

gitlab/v4/objects/jobs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from gitlab import utils
88
from gitlab.base import RESTManager, RESTObject
99
from gitlab.mixins import RefreshMixin, RetrieveMixin
10+
from gitlab.types import ArrayAttribute
1011

1112
__all__ = [
1213
"ProjectJob",
@@ -245,6 +246,7 @@ class ProjectJobManager(RetrieveMixin, RESTManager):
245246
_obj_cls = ProjectJob
246247
_from_parent_attrs = {"project_id": "id"}
247248
_list_filters = ("scope",)
249+
_types = {"scope": ArrayAttribute}
248250

249251
def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> ProjectJob:
250252
return cast(ProjectJob, super().get(id=id, lazy=lazy, **kwargs))

gitlab/v4/objects/members.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@ class GroupMemberManager(CRUDMixin, RESTManager):
3737
_obj_cls = GroupMember
3838
_from_parent_attrs = {"group_id": "id"}
3939
_create_attrs = RequiredOptional(
40-
required=("access_level", "user_id"), optional=("expires_at",)
40+
required=("access_level", "user_id"),
41+
optional=("expires_at", "tasks_to_be_done"),
4142
)
4243
_update_attrs = RequiredOptional(
4344
required=("access_level",), optional=("expires_at",)
4445
)
45-
_types = {"user_ids": types.ArrayAttribute}
46+
_types = {
47+
"user_ids": types.ArrayAttribute,
48+
"tasks_to_be_done": types.ArrayAttribute,
49+
}
4650

4751
def get(
4852
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
@@ -97,12 +101,16 @@ class ProjectMemberManager(CRUDMixin, RESTManager):
97101
_obj_cls = ProjectMember
98102
_from_parent_attrs = {"project_id": "id"}
99103
_create_attrs = RequiredOptional(
100-
required=("access_level", "user_id"), optional=("expires_at",)
104+
required=("access_level", "user_id"),
105+
optional=("expires_at", "tasks_to_be_done"),
101106
)
102107
_update_attrs = RequiredOptional(
103108
required=("access_level",), optional=("expires_at",)
104109
)
105-
_types = {"user_ids": types.ArrayAttribute}
110+
_types = {
111+
"user_ids": types.ArrayAttribute,
112+
"tasks_to_be_dones": types.ArrayAttribute,
113+
}
106114

107115
def get(
108116
self, id: Union[str, int], lazy: bool = False, **kwargs: Any

gitlab/v4/objects/personal_access_tokens.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from gitlab.base import RESTManager, RESTObject
22
from gitlab.mixins import CreateMixin, DeleteMixin, ListMixin, ObjectDeleteMixin
3-
from gitlab.types import RequiredOptional
3+
from gitlab.types import ArrayAttribute, RequiredOptional
44

55
__all__ = [
66
"PersonalAccessToken",
@@ -31,3 +31,4 @@ class UserPersonalAccessTokenManager(CreateMixin, RESTManager):
3131
_create_attrs = RequiredOptional(
3232
required=("name", "scopes"), optional=("expires_at",)
3333
)
34+
_types = {"scopes": ArrayAttribute}

gitlab/v4/objects/project_access_tokens.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from gitlab.base import RESTManager, RESTObject
22
from gitlab.mixins import CreateMixin, DeleteMixin, ListMixin, ObjectDeleteMixin
3+
from gitlab.types import ArrayAttribute, RequiredOptional
34

45
__all__ = [
56
"ProjectAccessToken",
@@ -15,3 +16,7 @@ class ProjectAccessTokenManager(ListMixin, CreateMixin, DeleteMixin, RESTManager
1516
_path = "/projects/{project_id}/access_tokens"
1617
_obj_cls = ProjectAccessToken
1718
_from_parent_attrs = {"project_id": "id"}
19+
_create_attrs = RequiredOptional(
20+
required=("name", "scopes"), optional=("access_level", "expires_at")
21+
)
22+
_types = {"scopes": ArrayAttribute}

gitlab/v4/objects/projects.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ class ProjectManager(CRUDMixin, RESTManager):
692692
"snippets_enabled",
693693
"squash_option",
694694
"tag_list",
695+
"topics",
695696
"template_name",
696697
"template_project_id",
697698
"use_custom_template",
@@ -763,6 +764,7 @@ class ProjectManager(CRUDMixin, RESTManager):
763764
"squash_option",
764765
"suggestion_commit_message",
765766
"tag_list",
767+
"topics",
766768
"visibility",
767769
"wiki_access_level",
768770
"wiki_enabled",
@@ -799,6 +801,7 @@ class ProjectManager(CRUDMixin, RESTManager):
799801
_types = {
800802
"avatar": types.ImageAttribute,
801803
"topic": types.CommaSeparatedListAttribute,
804+
"topics": types.ArrayAttribute,
802805
}
803806

804807
def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Project:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy