summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNejc Habjan <nejc.habjan@siemens.com>2022-07-28 12:54:46 +0200
committerJohn Villalovos <john@sodarock.com>2022-07-28 07:41:36 -0700
commitd9126cd802dd3cfe529fa940300113c4ead3054b (patch)
tree973e9029a685ce9dbc3ea1f3ba35b356d9f3562d
parent005ba93074d391f818c39e46390723a0d0d16098 (diff)
downloadgitlab-d9126cd802dd3cfe529fa940300113c4ead3054b.tar.gz
fix: support array types for most resources
-rw-r--r--gitlab/v4/objects/broadcast_messages.py15
-rw-r--r--gitlab/v4/objects/deploy_tokens.py6
-rw-r--r--gitlab/v4/objects/environments.py3
-rw-r--r--gitlab/v4/objects/group_access_tokens.py5
-rw-r--r--gitlab/v4/objects/invitations.py4
-rw-r--r--gitlab/v4/objects/jobs.py2
-rw-r--r--gitlab/v4/objects/members.py16
-rw-r--r--gitlab/v4/objects/personal_access_tokens.py3
-rw-r--r--gitlab/v4/objects/project_access_tokens.py5
-rw-r--r--gitlab/v4/objects/projects.py3
-rw-r--r--gitlab/v4/objects/releases.py3
-rw-r--r--gitlab/v4/objects/statistics.py7
-rw-r--r--gitlab/v4/objects/users.py3
13 files changed, 61 insertions, 14 deletions
diff --git a/gitlab/v4/objects/broadcast_messages.py b/gitlab/v4/objects/broadcast_messages.py
index 3beb4ac..e3bda68 100644
--- a/gitlab/v4/objects/broadcast_messages.py
+++ b/gitlab/v4/objects/broadcast_messages.py
@@ -2,7 +2,7 @@ from typing import Any, cast, Union
from gitlab.base import RESTManager, RESTObject
from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin
-from gitlab.types import RequiredOptional
+from gitlab.types import ArrayAttribute, RequiredOptional
__all__ = [
"BroadcastMessage",
@@ -19,11 +19,20 @@ class BroadcastMessageManager(CRUDMixin, RESTManager):
_obj_cls = BroadcastMessage
_create_attrs = RequiredOptional(
- required=("message",), optional=("starts_at", "ends_at", "color", "font")
+ required=("message",),
+ optional=("starts_at", "ends_at", "color", "font", "target_access_levels"),
)
_update_attrs = RequiredOptional(
- optional=("message", "starts_at", "ends_at", "color", "font")
+ optional=(
+ "message",
+ "starts_at",
+ "ends_at",
+ "color",
+ "font",
+ "target_access_levels",
+ )
)
+ _types = {"target_access_levels": ArrayAttribute}
def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
diff --git a/gitlab/v4/objects/deploy_tokens.py b/gitlab/v4/objects/deploy_tokens.py
index 32bb5fe..e35bf22 100644
--- a/gitlab/v4/objects/deploy_tokens.py
+++ b/gitlab/v4/objects/deploy_tokens.py
@@ -48,7 +48,8 @@ class GroupDeployTokenManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManag
"username",
),
)
- _types = {"scopes": types.CommaSeparatedListAttribute}
+ _list_filters = ("scopes",)
+ _types = {"scopes": types.ArrayAttribute}
def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
@@ -74,7 +75,8 @@ class ProjectDeployTokenManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTMan
"username",
),
)
- _types = {"scopes": types.CommaSeparatedListAttribute}
+ _list_filters = ("scopes",)
+ _types = {"scopes": types.ArrayAttribute}
def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
diff --git a/gitlab/v4/objects/environments.py b/gitlab/v4/objects/environments.py
index a8bd9d5..1961f8a 100644
--- a/gitlab/v4/objects/environments.py
+++ b/gitlab/v4/objects/environments.py
@@ -13,7 +13,7 @@ from gitlab.mixins import (
SaveMixin,
UpdateMixin,
)
-from gitlab.types import RequiredOptional
+from gitlab.types import ArrayAttribute, RequiredOptional
__all__ = [
"ProjectEnvironment",
@@ -77,6 +77,7 @@ class ProjectProtectedEnvironmentManager(
),
optional=("required_approval_count", "approval_rules"),
)
+ _types = {"deploy_access_levels": ArrayAttribute, "approval_rules": ArrayAttribute}
def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
diff --git a/gitlab/v4/objects/group_access_tokens.py b/gitlab/v4/objects/group_access_tokens.py
index ca3cbcf..5210981 100644
--- a/gitlab/v4/objects/group_access_tokens.py
+++ b/gitlab/v4/objects/group_access_tokens.py
@@ -1,5 +1,6 @@
from gitlab.base import RESTManager, RESTObject
from gitlab.mixins import CreateMixin, DeleteMixin, ListMixin, ObjectDeleteMixin
+from gitlab.types import ArrayAttribute, RequiredOptional
__all__ = [
"GroupAccessToken",
@@ -15,3 +16,7 @@ class GroupAccessTokenManager(ListMixin, CreateMixin, DeleteMixin, RESTManager):
_path = "/groups/{group_id}/access_tokens"
_obj_cls = GroupAccessToken
_from_parent_attrs = {"group_id": "id"}
+ _create_attrs = RequiredOptional(
+ required=("name", "scopes"), optional=("access_level", "expires_at")
+ )
+ _types = {"scopes": ArrayAttribute}
diff --git a/gitlab/v4/objects/invitations.py b/gitlab/v4/objects/invitations.py
index 22c72f1..43fbb2d 100644
--- a/gitlab/v4/objects/invitations.py
+++ b/gitlab/v4/objects/invitations.py
@@ -3,7 +3,7 @@ from typing import Any, cast, Union
from gitlab.base import RESTManager, RESTObject
from gitlab.exceptions import GitlabInvitationError
from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin
-from gitlab.types import CommaSeparatedListAttribute, RequiredOptional
+from gitlab.types import ArrayAttribute, CommaSeparatedListAttribute, RequiredOptional
__all__ = [
"ProjectInvitation",
@@ -48,6 +48,7 @@ class ProjectInvitationManager(InvitationMixin, RESTManager):
_types = {
"email": CommaSeparatedListAttribute,
"user_id": CommaSeparatedListAttribute,
+ "tasks_to_be_done": ArrayAttribute,
}
def get(
@@ -81,6 +82,7 @@ class GroupInvitationManager(InvitationMixin, RESTManager):
_types = {
"email": CommaSeparatedListAttribute,
"user_id": CommaSeparatedListAttribute,
+ "tasks_to_be_done": ArrayAttribute,
}
def get(
diff --git a/gitlab/v4/objects/jobs.py b/gitlab/v4/objects/jobs.py
index cfe1e62..952c295 100644
--- a/gitlab/v4/objects/jobs.py
+++ b/gitlab/v4/objects/jobs.py
@@ -7,6 +7,7 @@ from gitlab import exceptions as exc
from gitlab import utils
from gitlab.base import RESTManager, RESTObject
from gitlab.mixins import RefreshMixin, RetrieveMixin
+from gitlab.types import ArrayAttribute
__all__ = [
"ProjectJob",
@@ -245,6 +246,7 @@ class ProjectJobManager(RetrieveMixin, RESTManager):
_obj_cls = ProjectJob
_from_parent_attrs = {"project_id": "id"}
_list_filters = ("scope",)
+ _types = {"scope": ArrayAttribute}
def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> ProjectJob:
return cast(ProjectJob, super().get(id=id, lazy=lazy, **kwargs))
diff --git a/gitlab/v4/objects/members.py b/gitlab/v4/objects/members.py
index af25085..8751fd5 100644
--- a/gitlab/v4/objects/members.py
+++ b/gitlab/v4/objects/members.py
@@ -37,12 +37,16 @@ class GroupMemberManager(CRUDMixin, RESTManager):
_obj_cls = GroupMember
_from_parent_attrs = {"group_id": "id"}
_create_attrs = RequiredOptional(
- required=("access_level", "user_id"), optional=("expires_at",)
+ required=("access_level", "user_id"),
+ optional=("expires_at", "tasks_to_be_done"),
)
_update_attrs = RequiredOptional(
required=("access_level",), optional=("expires_at",)
)
- _types = {"user_ids": types.ArrayAttribute}
+ _types = {
+ "user_ids": types.ArrayAttribute,
+ "tasks_to_be_done": types.ArrayAttribute,
+ }
def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
@@ -97,12 +101,16 @@ class ProjectMemberManager(CRUDMixin, RESTManager):
_obj_cls = ProjectMember
_from_parent_attrs = {"project_id": "id"}
_create_attrs = RequiredOptional(
- required=("access_level", "user_id"), optional=("expires_at",)
+ required=("access_level", "user_id"),
+ optional=("expires_at", "tasks_to_be_done"),
)
_update_attrs = RequiredOptional(
required=("access_level",), optional=("expires_at",)
)
- _types = {"user_ids": types.ArrayAttribute}
+ _types = {
+ "user_ids": types.ArrayAttribute,
+ "tasks_to_be_dones": types.ArrayAttribute,
+ }
def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
diff --git a/gitlab/v4/objects/personal_access_tokens.py b/gitlab/v4/objects/personal_access_tokens.py
index 5e4e54b..fa80e9a 100644
--- a/gitlab/v4/objects/personal_access_tokens.py
+++ b/gitlab/v4/objects/personal_access_tokens.py
@@ -1,6 +1,6 @@
from gitlab.base import RESTManager, RESTObject
from gitlab.mixins import CreateMixin, DeleteMixin, ListMixin, ObjectDeleteMixin
-from gitlab.types import RequiredOptional
+from gitlab.types import ArrayAttribute, RequiredOptional
__all__ = [
"PersonalAccessToken",
@@ -31,3 +31,4 @@ class UserPersonalAccessTokenManager(CreateMixin, RESTManager):
_create_attrs = RequiredOptional(
required=("name", "scopes"), optional=("expires_at",)
)
+ _types = {"scopes": ArrayAttribute}
diff --git a/gitlab/v4/objects/project_access_tokens.py b/gitlab/v4/objects/project_access_tokens.py
index 6293f21..185cb6f 100644
--- a/gitlab/v4/objects/project_access_tokens.py
+++ b/gitlab/v4/objects/project_access_tokens.py
@@ -1,5 +1,6 @@
from gitlab.base import RESTManager, RESTObject
from gitlab.mixins import CreateMixin, DeleteMixin, ListMixin, ObjectDeleteMixin
+from gitlab.types import ArrayAttribute, RequiredOptional
__all__ = [
"ProjectAccessToken",
@@ -15,3 +16,7 @@ class ProjectAccessTokenManager(ListMixin, CreateMixin, DeleteMixin, RESTManager
_path = "/projects/{project_id}/access_tokens"
_obj_cls = ProjectAccessToken
_from_parent_attrs = {"project_id": "id"}
+ _create_attrs = RequiredOptional(
+ required=("name", "scopes"), optional=("access_level", "expires_at")
+ )
+ _types = {"scopes": ArrayAttribute}
diff --git a/gitlab/v4/objects/projects.py b/gitlab/v4/objects/projects.py
index 803239f..8f3b381 100644
--- a/gitlab/v4/objects/projects.py
+++ b/gitlab/v4/objects/projects.py
@@ -692,6 +692,7 @@ class ProjectManager(CRUDMixin, RESTManager):
"snippets_enabled",
"squash_option",
"tag_list",
+ "topics",
"template_name",
"template_project_id",
"use_custom_template",
@@ -763,6 +764,7 @@ class ProjectManager(CRUDMixin, RESTManager):
"squash_option",
"suggestion_commit_message",
"tag_list",
+ "topics",
"visibility",
"wiki_access_level",
"wiki_enabled",
@@ -799,6 +801,7 @@ class ProjectManager(CRUDMixin, RESTManager):
_types = {
"avatar": types.ImageAttribute,
"topic": types.CommaSeparatedListAttribute,
+ "topics": types.ArrayAttribute,
}
def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Project:
diff --git a/gitlab/v4/objects/releases.py b/gitlab/v4/objects/releases.py
index 788c050..7df9a11 100644
--- a/gitlab/v4/objects/releases.py
+++ b/gitlab/v4/objects/releases.py
@@ -2,7 +2,7 @@ from typing import Any, cast, Union
from gitlab.base import RESTManager, RESTObject
from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin
-from gitlab.types import RequiredOptional
+from gitlab.types import ArrayAttribute, RequiredOptional
__all__ = [
"ProjectRelease",
@@ -28,6 +28,7 @@ class ProjectReleaseManager(CRUDMixin, RESTManager):
_update_attrs = RequiredOptional(
optional=("name", "description", "milestones", "released_at")
)
+ _types = {"milestones": ArrayAttribute}
def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
diff --git a/gitlab/v4/objects/statistics.py b/gitlab/v4/objects/statistics.py
index 3176674..1de963e 100644
--- a/gitlab/v4/objects/statistics.py
+++ b/gitlab/v4/objects/statistics.py
@@ -2,6 +2,7 @@ from typing import Any, cast
from gitlab.base import RESTManager, RESTObject
from gitlab.mixins import GetWithoutIdMixin, RefreshMixin
+from gitlab.types import ArrayAttribute
__all__ = [
"GroupIssuesStatistics",
@@ -35,6 +36,8 @@ class IssuesStatistics(RefreshMixin, RESTObject):
class IssuesStatisticsManager(GetWithoutIdMixin, RESTManager):
_path = "/issues_statistics"
_obj_cls = IssuesStatistics
+ _list_filters = ("iids",)
+ _types = {"iids": ArrayAttribute}
def get(self, **kwargs: Any) -> IssuesStatistics:
return cast(IssuesStatistics, super().get(**kwargs))
@@ -48,6 +51,8 @@ class GroupIssuesStatisticsManager(GetWithoutIdMixin, RESTManager):
_path = "/groups/{group_id}/issues_statistics"
_obj_cls = GroupIssuesStatistics
_from_parent_attrs = {"group_id": "id"}
+ _list_filters = ("iids",)
+ _types = {"iids": ArrayAttribute}
def get(self, **kwargs: Any) -> GroupIssuesStatistics:
return cast(GroupIssuesStatistics, super().get(**kwargs))
@@ -61,6 +66,8 @@ class ProjectIssuesStatisticsManager(GetWithoutIdMixin, RESTManager):
_path = "/projects/{project_id}/issues_statistics"
_obj_cls = ProjectIssuesStatistics
_from_parent_attrs = {"project_id": "id"}
+ _list_filters = ("iids",)
+ _types = {"iids": ArrayAttribute}
def get(self, **kwargs: Any) -> ProjectIssuesStatistics:
return cast(ProjectIssuesStatistics, super().get(**kwargs))
diff --git a/gitlab/v4/objects/users.py b/gitlab/v4/objects/users.py
index 69d875e..7395313 100644
--- a/gitlab/v4/objects/users.py
+++ b/gitlab/v4/objects/users.py
@@ -23,7 +23,7 @@ from gitlab.mixins import (
SaveMixin,
UpdateMixin,
)
-from gitlab.types import RequiredOptional
+from gitlab.types import ArrayAttribute, RequiredOptional
from .custom_attributes import UserCustomAttributeManager # noqa: F401
from .events import UserEventManager # noqa: F401
@@ -543,6 +543,7 @@ class UserImpersonationTokenManager(NoUpdateMixin, RESTManager):
required=("name", "scopes"), optional=("expires_at",)
)
_list_filters = ("state",)
+ _types = {"scopes": ArrayAttribute}
def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any