summaryrefslogtreecommitdiff
path: root/gitlab/v4
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2022-01-22 10:47:43 -0800
committerJohn L. Villalovos <john@sodarock.com>2022-01-22 10:47:43 -0800
commit1905548ec251c88bb6a2b6677940dac9c1ab7167 (patch)
tree749471d43b6a8297727c8209330c95a7d3ae0d6a /gitlab/v4
parent8dfed0c362af2c5e936011fd0b488b8b05e8a8a0 (diff)
downloadgitlab-jlvillal/arrays.tar.gz
fix: use the [] after key names for array variablesjlvillal/arrays
1. Create a new CommaSeparatedListAttribute class. This is to indicate types which are sent to the GitLab server as comma-separated-strings (CSV) but we have been allowing users to use a list-of-strings. These values are NOT array values, so adding [] to the key name breaks them. 2. Rename ListAttribute to ArrayAttribute. 3. If a value is of type ArrayAttribute then append '[]' to the name of the value. 4. Move processing of most GitlabAttributes into the client.py:http_request() method. Now we convert our params into a list of tuples so that we can have multiple identical keys but with different values. Fixes: #1698
Diffstat (limited to 'gitlab/v4')
-rw-r--r--gitlab/v4/objects/deploy_tokens.py4
-rw-r--r--gitlab/v4/objects/epics.py2
-rw-r--r--gitlab/v4/objects/groups.py4
-rw-r--r--gitlab/v4/objects/issues.py6
-rw-r--r--gitlab/v4/objects/members.py4
-rw-r--r--gitlab/v4/objects/merge_requests.py22
-rw-r--r--gitlab/v4/objects/milestones.py4
-rw-r--r--gitlab/v4/objects/projects.py7
-rw-r--r--gitlab/v4/objects/runners.py6
-rw-r--r--gitlab/v4/objects/settings.py12
-rw-r--r--gitlab/v4/objects/users.py2
11 files changed, 38 insertions, 35 deletions
diff --git a/gitlab/v4/objects/deploy_tokens.py b/gitlab/v4/objects/deploy_tokens.py
index 97f3270..563c1d6 100644
--- a/gitlab/v4/objects/deploy_tokens.py
+++ b/gitlab/v4/objects/deploy_tokens.py
@@ -39,7 +39,7 @@ class GroupDeployTokenManager(ListMixin, CreateMixin, DeleteMixin, RESTManager):
"username",
),
)
- _types = {"scopes": types.ListAttribute}
+ _types = {"scopes": types.CommaSeparatedListAttribute}
class ProjectDeployToken(ObjectDeleteMixin, RESTObject):
@@ -60,4 +60,4 @@ class ProjectDeployTokenManager(ListMixin, CreateMixin, DeleteMixin, RESTManager
"username",
),
)
- _types = {"scopes": types.ListAttribute}
+ _types = {"scopes": types.CommaSeparatedListAttribute}
diff --git a/gitlab/v4/objects/epics.py b/gitlab/v4/objects/epics.py
index bb0bb79..d33821c 100644
--- a/gitlab/v4/objects/epics.py
+++ b/gitlab/v4/objects/epics.py
@@ -42,7 +42,7 @@ class GroupEpicManager(CRUDMixin, RESTManager):
_update_attrs = RequiredOptional(
optional=("title", "labels", "description", "start_date", "end_date"),
)
- _types = {"labels": types.ListAttribute}
+ _types = {"labels": types.CommaSeparatedListAttribute}
def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> GroupEpic:
return cast(GroupEpic, super().get(id=id, lazy=lazy, **kwargs))
diff --git a/gitlab/v4/objects/groups.py b/gitlab/v4/objects/groups.py
index f2b90d1..99d10ce 100644
--- a/gitlab/v4/objects/groups.py
+++ b/gitlab/v4/objects/groups.py
@@ -314,7 +314,7 @@ class GroupManager(CRUDMixin, RESTManager):
"shared_runners_setting",
),
)
- _types = {"avatar": types.ImageAttribute, "skip_groups": types.ListAttribute}
+ _types = {"avatar": types.ImageAttribute, "skip_groups": types.ArrayAttribute}
def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Group:
return cast(Group, super().get(id=id, lazy=lazy, **kwargs))
@@ -374,7 +374,7 @@ class GroupSubgroupManager(ListMixin, RESTManager):
"with_custom_attributes",
"min_access_level",
)
- _types = {"skip_groups": types.ListAttribute}
+ _types = {"skip_groups": types.ArrayAttribute}
class GroupDescendantGroup(RESTObject):
diff --git a/gitlab/v4/objects/issues.py b/gitlab/v4/objects/issues.py
index 585e02e..f20252b 100644
--- a/gitlab/v4/objects/issues.py
+++ b/gitlab/v4/objects/issues.py
@@ -65,7 +65,7 @@ class IssueManager(RetrieveMixin, RESTManager):
"updated_after",
"updated_before",
)
- _types = {"iids": types.ListAttribute, "labels": types.ListAttribute}
+ _types = {"iids": types.ArrayAttribute, "labels": types.CommaSeparatedListAttribute}
def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Issue:
return cast(Issue, super().get(id=id, lazy=lazy, **kwargs))
@@ -95,7 +95,7 @@ class GroupIssueManager(ListMixin, RESTManager):
"updated_after",
"updated_before",
)
- _types = {"iids": types.ListAttribute, "labels": types.ListAttribute}
+ _types = {"iids": types.ArrayAttribute, "labels": types.CommaSeparatedListAttribute}
class ProjectIssue(
@@ -233,7 +233,7 @@ class ProjectIssueManager(CRUDMixin, RESTManager):
"discussion_locked",
),
)
- _types = {"iids": types.ListAttribute, "labels": types.ListAttribute}
+ _types = {"iids": types.ArrayAttribute, "labels": types.CommaSeparatedListAttribute}
def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
diff --git a/gitlab/v4/objects/members.py b/gitlab/v4/objects/members.py
index c7be039..5ee0b0e 100644
--- a/gitlab/v4/objects/members.py
+++ b/gitlab/v4/objects/members.py
@@ -41,7 +41,7 @@ class GroupMemberManager(CRUDMixin, RESTManager):
_update_attrs = RequiredOptional(
required=("access_level",), optional=("expires_at",)
)
- _types = {"user_ids": types.ListAttribute}
+ _types = {"user_ids": types.ArrayAttribute}
def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
@@ -101,7 +101,7 @@ class ProjectMemberManager(CRUDMixin, RESTManager):
_update_attrs = RequiredOptional(
required=("access_level",), optional=("expires_at",)
)
- _types = {"user_ids": types.ListAttribute}
+ _types = {"user_ids": types.ArrayAttribute}
def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
diff --git a/gitlab/v4/objects/merge_requests.py b/gitlab/v4/objects/merge_requests.py
index 9a4f8c8..9f2368b 100644
--- a/gitlab/v4/objects/merge_requests.py
+++ b/gitlab/v4/objects/merge_requests.py
@@ -95,10 +95,10 @@ class MergeRequestManager(ListMixin, RESTManager):
"deployed_after",
)
_types = {
- "approver_ids": types.ListAttribute,
- "approved_by_ids": types.ListAttribute,
- "in": types.ListAttribute,
- "labels": types.ListAttribute,
+ "approver_ids": types.ArrayAttribute,
+ "approved_by_ids": types.ArrayAttribute,
+ "in": types.CommaSeparatedListAttribute,
+ "labels": types.CommaSeparatedListAttribute,
}
@@ -133,9 +133,9 @@ class GroupMergeRequestManager(ListMixin, RESTManager):
"wip",
)
_types = {
- "approver_ids": types.ListAttribute,
- "approved_by_ids": types.ListAttribute,
- "labels": types.ListAttribute,
+ "approver_ids": types.ArrayAttribute,
+ "approved_by_ids": types.ArrayAttribute,
+ "labels": types.CommaSeparatedListAttribute,
}
@@ -455,10 +455,10 @@ class ProjectMergeRequestManager(CRUDMixin, RESTManager):
"wip",
)
_types = {
- "approver_ids": types.ListAttribute,
- "approved_by_ids": types.ListAttribute,
- "iids": types.ListAttribute,
- "labels": types.ListAttribute,
+ "approver_ids": types.ArrayAttribute,
+ "approved_by_ids": types.ArrayAttribute,
+ "iids": types.ArrayAttribute,
+ "labels": types.CommaSeparatedListAttribute,
}
def get(
diff --git a/gitlab/v4/objects/milestones.py b/gitlab/v4/objects/milestones.py
index 6b1e28d..da75826 100644
--- a/gitlab/v4/objects/milestones.py
+++ b/gitlab/v4/objects/milestones.py
@@ -93,7 +93,7 @@ class GroupMilestoneManager(CRUDMixin, RESTManager):
optional=("title", "description", "due_date", "start_date", "state_event"),
)
_list_filters = ("iids", "state", "search")
- _types = {"iids": types.ListAttribute}
+ _types = {"iids": types.ArrayAttribute}
def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
@@ -177,7 +177,7 @@ class ProjectMilestoneManager(CRUDMixin, RESTManager):
optional=("title", "description", "due_date", "start_date", "state_event"),
)
_list_filters = ("iids", "state", "search")
- _types = {"iids": types.ListAttribute}
+ _types = {"iids": types.ArrayAttribute}
def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
diff --git a/gitlab/v4/objects/projects.py b/gitlab/v4/objects/projects.py
index f9988db..23f3d3c 100644
--- a/gitlab/v4/objects/projects.py
+++ b/gitlab/v4/objects/projects.py
@@ -125,7 +125,7 @@ class ProjectGroupManager(ListMixin, RESTManager):
"shared_min_access_level",
"shared_visible_only",
)
- _types = {"skip_groups": types.ListAttribute}
+ _types = {"skip_groups": types.ArrayAttribute}
class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTObject):
@@ -807,7 +807,10 @@ class ProjectManager(CRUDMixin, RESTManager):
"with_merge_requests_enabled",
"with_programming_language",
)
- _types = {"avatar": types.ImageAttribute, "topic": types.ListAttribute}
+ _types = {
+ "avatar": types.ImageAttribute,
+ "topic": types.CommaSeparatedListAttribute,
+ }
def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Project:
return cast(Project, super().get(id=id, lazy=lazy, **kwargs))
diff --git a/gitlab/v4/objects/runners.py b/gitlab/v4/objects/runners.py
index d340b99..1826945 100644
--- a/gitlab/v4/objects/runners.py
+++ b/gitlab/v4/objects/runners.py
@@ -68,7 +68,7 @@ class RunnerManager(CRUDMixin, RESTManager):
),
)
_list_filters = ("scope", "tag_list")
- _types = {"tag_list": types.ListAttribute}
+ _types = {"tag_list": types.CommaSeparatedListAttribute}
@cli.register_custom_action("RunnerManager", tuple(), ("scope",))
@exc.on_http_error(exc.GitlabListError)
@@ -130,7 +130,7 @@ class GroupRunnerManager(ListMixin, RESTManager):
_from_parent_attrs = {"group_id": "id"}
_create_attrs = RequiredOptional(required=("runner_id",))
_list_filters = ("scope", "tag_list")
- _types = {"tag_list": types.ListAttribute}
+ _types = {"tag_list": types.CommaSeparatedListAttribute}
class ProjectRunner(ObjectDeleteMixin, RESTObject):
@@ -143,4 +143,4 @@ class ProjectRunnerManager(CreateMixin, DeleteMixin, ListMixin, RESTManager):
_from_parent_attrs = {"project_id": "id"}
_create_attrs = RequiredOptional(required=("runner_id",))
_list_filters = ("scope", "tag_list")
- _types = {"tag_list": types.ListAttribute}
+ _types = {"tag_list": types.CommaSeparatedListAttribute}
diff --git a/gitlab/v4/objects/settings.py b/gitlab/v4/objects/settings.py
index 96f2539..7612403 100644
--- a/gitlab/v4/objects/settings.py
+++ b/gitlab/v4/objects/settings.py
@@ -80,12 +80,12 @@ class ApplicationSettingsManager(GetWithoutIdMixin, UpdateMixin, RESTManager):
),
)
_types = {
- "asset_proxy_allowlist": types.ListAttribute,
- "disabled_oauth_sign_in_sources": types.ListAttribute,
- "domain_allowlist": types.ListAttribute,
- "domain_denylist": types.ListAttribute,
- "import_sources": types.ListAttribute,
- "restricted_visibility_levels": types.ListAttribute,
+ "asset_proxy_allowlist": types.ArrayAttribute,
+ "disabled_oauth_sign_in_sources": types.ArrayAttribute,
+ "domain_allowlist": types.ArrayAttribute,
+ "domain_denylist": types.ArrayAttribute,
+ "import_sources": types.ArrayAttribute,
+ "restricted_visibility_levels": types.ArrayAttribute,
}
@exc.on_http_error(exc.GitlabUpdateError)
diff --git a/gitlab/v4/objects/users.py b/gitlab/v4/objects/users.py
index f5b8f6c..b2de337 100644
--- a/gitlab/v4/objects/users.py
+++ b/gitlab/v4/objects/users.py
@@ -369,7 +369,7 @@ class ProjectUserManager(ListMixin, RESTManager):
_obj_cls = ProjectUser
_from_parent_attrs = {"project_id": "id"}
_list_filters = ("search", "skip_users")
- _types = {"skip_users": types.ListAttribute}
+ _types = {"skip_users": types.ArrayAttribute}
class UserEmail(ObjectDeleteMixin, RESTObject):