Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: support array types for most resources#2196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JohnVillalovos merged 3 commits intomainfromfix/array-attributes
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletiondocs/cli-examples.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -111,6 +111,12 @@ Get a specific user by id:

$ gitlab user get --id 3

Create a user impersonation token (admin-only):

.. code-block:: console

gitlab user-impersonation-token create --user-id 2 --name test-token --scopes api,read_user

Deploy tokens
-------------

Expand All@@ -119,14 +125,55 @@ Create a deploy token for a project:
.. code-block:: console

$ gitlab -v project-deploy-token create --project-id 2 \
--name bar --username root --expires-at "2021-09-09" --scopes "read_repository"
--name bar --username root --expires-at "2021-09-09" --scopes "api,read_repository"

List deploy tokens for a group:

.. code-block:: console

$ gitlab -v group-deploy-token list --group-id 3

Resource access tokens
----------------------

Create a project access token:

.. code-block:: console

$ gitlab -v project-access-token create --project-id 2 \
--name project-token --expires-at "2023-01-01" --scopes "api,read_repository"

List project access tokens:

.. code-block:: console

$ gitlab -v project-access-token list --project-id 3

Revoke a project access token:

.. code-block:: console

$ gitlab project-access-token delete --project-id 3 --id 1

Create a group access token:

.. code-block:: console

$ gitlab -v group-access-token create --group-id 2 \
--name group-token --expires-at "2022-01-01" --scopes "api,read_repository"

List group access tokens:

.. code-block:: console

$ gitlab -v group-access-token list --group-id 3

Revoke a group access token:

.. code-block:: console

$ gitlab group-access-token delete --group-id 3 --id 1

Packages
--------

Expand Down
15 changes: 12 additions & 3 deletionsgitlab/v4/objects/broadcast_messages.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@

from gitlab.base import RESTManager, RESTObject
from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin
from gitlab.types import RequiredOptional
from gitlab.types importArrayAttribute,RequiredOptional

__all__ = [
"BroadcastMessage",
Expand All@@ -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
Expand Down
6 changes: 4 additions & 2 deletionsgitlab/v4/objects/deploy_tokens.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand All@@ -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
Expand Down
3 changes: 2 additions & 1 deletiongitlab/v4/objects/environments.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,7 @@
SaveMixin,
UpdateMixin,
)
from gitlab.types import RequiredOptional
from gitlab.types importArrayAttribute,RequiredOptional

__all__ = [
"ProjectEnvironment",
Expand DownExpand Up@@ -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
Expand Down
5 changes: 5 additions & 0 deletionsgitlab/v4/objects/group_access_tokens.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -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",
Expand All@@ -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}
4 changes: 3 additions & 1 deletiongitlab/v4/objects/invitations.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@
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 importArrayAttribute,CommaSeparatedListAttribute, RequiredOptional

__all__ = [
"ProjectInvitation",
Expand DownExpand Up@@ -48,6 +48,7 @@ class ProjectInvitationManager(InvitationMixin, RESTManager):
_types = {
"email": CommaSeparatedListAttribute,
"user_id": CommaSeparatedListAttribute,
"tasks_to_be_done": ArrayAttribute,
}

def get(
Expand DownExpand Up@@ -81,6 +82,7 @@ class GroupInvitationManager(InvitationMixin, RESTManager):
_types = {
"email": CommaSeparatedListAttribute,
"user_id": CommaSeparatedListAttribute,
"tasks_to_be_done": ArrayAttribute,
}

def get(
Expand Down
2 changes: 2 additions & 0 deletionsgitlab/v4/objects/jobs.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@
from gitlab import utils
from gitlab.base import RESTManager, RESTObject
from gitlab.mixins import RefreshMixin, RetrieveMixin
from gitlab.types import ArrayAttribute

__all__ = [
"ProjectJob",
Expand DownExpand Up@@ -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))
16 changes: 12 additions & 4 deletionsgitlab/v4/objects/members.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand DownExpand Up@@ -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
Expand Down
3 changes: 2 additions & 1 deletiongitlab/v4/objects/personal_access_tokens.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -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 importArrayAttribute,RequiredOptional

__all__ = [
"PersonalAccessToken",
Expand DownExpand Up@@ -31,3 +31,4 @@ class UserPersonalAccessTokenManager(CreateMixin, RESTManager):
_create_attrs = RequiredOptional(
required=("name", "scopes"), optional=("expires_at",)
)
_types = {"scopes": ArrayAttribute}
5 changes: 5 additions & 0 deletionsgitlab/v4/objects/project_access_tokens.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -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",
Expand All@@ -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}
3 changes: 3 additions & 0 deletionsgitlab/v4/objects/projects.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -692,6 +692,7 @@ class ProjectManager(CRUDMixin, RESTManager):
"snippets_enabled",
"squash_option",
"tag_list",
"topics",
"template_name",
"template_project_id",
"use_custom_template",
Expand DownExpand Up@@ -763,6 +764,7 @@ class ProjectManager(CRUDMixin, RESTManager):
"squash_option",
"suggestion_commit_message",
"tag_list",
"topics",
"visibility",
"wiki_access_level",
"wiki_enabled",
Expand DownExpand Up@@ -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:
Expand Down
3 changes: 2 additions & 1 deletiongitlab/v4/objects/releases.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@

from gitlab.base import RESTManager, RESTObject
from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin
from gitlab.types import RequiredOptional
from gitlab.types importArrayAttribute,RequiredOptional

__all__ = [
"ProjectRelease",
Expand All@@ -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
Expand Down
7 changes: 7 additions & 0 deletionsgitlab/v4/objects/statistics.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@

from gitlab.base import RESTManager, RESTObject
from gitlab.mixins import GetWithoutIdMixin, RefreshMixin
from gitlab.types import ArrayAttribute

__all__ = [
"GroupIssuesStatistics",
Expand DownExpand Up@@ -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))
Expand All@@ -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))
Expand All@@ -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))
3 changes: 2 additions & 1 deletiongitlab/v4/objects/users.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@
SaveMixin,
UpdateMixin,
)
from gitlab.types import RequiredOptional
from gitlab.types importArrayAttribute,RequiredOptional

from .custom_attributes import UserCustomAttributeManager # noqa: F401
from .events import UserEventManager # noqa: F401
Expand DownExpand Up@@ -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
Expand Down
32 changes: 32 additions & 0 deletionstests/functional/cli/test_cli_resource_access_tokens.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,9 +8,41 @@ def test_list_project_access_tokens(gitlab_cli, project):
assert ret.success


def test_create_project_access_token_with_scopes(gitlab_cli, project):
cmd = [
"project-access-token",
"create",
"--project-id",
project.id,
"--name",
"test-token",
"--scopes",
"api,read_repository",
]
ret = gitlab_cli(cmd)

assert ret.success


@pytest.mark.skip(reason="Requires GitLab 14.7")
def test_list_group_access_tokens(gitlab_cli, group):
cmd = ["group-access-token", "list", "--group-id", group.id]
ret = gitlab_cli(cmd)

assert ret.success


def test_create_group_access_token_with_scopes(gitlab_cli, group):
cmd = [
"group-access-token",
"create",
"--group-id",
group.id,
"--name",
"test-token",
"--scopes",
"api,read_repository",
]
ret = gitlab_cli(cmd)

assert ret.success
Loading

[8]ページ先頭

©2009-2025 Movatter.jp