Skip to content

Commit 912f622

Browse files
committed
fix: make scopes work with multiple scope-names
1 parent 265dbbd commit 912f622

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

gitlab/types.py

+16
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,22 @@ def get_for_api(self):
4545
return ",".join(self._value)
4646

4747

48+
class ScopesListAttribute(ListAttribute):
49+
def set_from_cli(self, cli_value):
50+
if not cli_value.strip():
51+
self._value = []
52+
else:
53+
self._value = [item.strip() for item in cli_value.split(",")]
54+
55+
56+
def get_for_api(self):
57+
# Do not comma-split single value passed as string
58+
if isinstance(self._value, str):
59+
return [self._value]
60+
61+
return self._value
62+
63+
4864
class LowercaseStringAttribute(GitlabAttribute):
4965
def get_for_api(self):
5066
return str(self._value).lower()

gitlab/v4/objects/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class UserIdentityProviderManager(DeleteMixin, RESTManager):
229229

230230

231231
class UserImpersonationToken(ObjectDeleteMixin, RESTObject):
232-
pass
232+
_short_print_attr = "token"
233233

234234

235235
class UserImpersonationTokenManager(NoUpdateMixin, RESTManager):
@@ -238,6 +238,7 @@ class UserImpersonationTokenManager(NoUpdateMixin, RESTManager):
238238
_from_parent_attrs = {"user_id": "id"}
239239
_create_attrs = (("name", "scopes"), ("expires_at",))
240240
_list_filters = ("state",)
241+
_types = {"scopes": types.ScopesListAttribute}
241242

242243

243244
class UserMembership(RESTObject):
@@ -734,6 +735,7 @@ class ProjectDeployTokenManager(ListMixin, CreateMixin, DeleteMixin, RESTManager
734735
"username",
735736
),
736737
)
738+
_types = {"scopes": types.ScopesListAttribute}
737739

738740

739741
class GroupDeployToken(ObjectDeleteMixin, RESTObject):
@@ -754,6 +756,7 @@ class GroupDeployTokenManager(ListMixin, CreateMixin, DeleteMixin, RESTManager):
754756
"username",
755757
),
756758
)
759+
_types = {"scopes": types.ScopesListAttribute}
757760

758761

759762
class NotificationSettings(SaveMixin, RESTObject):
@@ -5786,3 +5789,4 @@ class ApplicationManager(ListMixin, CreateMixin, DeleteMixin, RESTManager):
57865789
_path = "/applications"
57875790
_obj_cls = Application
57885791
_create_attrs = (("name", "redirect_uri", "scopes"), ("confidential",))
5792+
_types = {"scopes": types.ScopesListAttribute}

0 commit comments

Comments
 (0)