Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add project protected tags management #581

Merged
merged 4 commits into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/gl_objects/projects.rst
Expand Up @@ -657,3 +657,36 @@ Edit project push rules::
Delete project push rules::

pr.delete()

Project protected tags
==================

Reference
---------

* v4 API:

+ :class:`gitlab.v4.objects.ProjectProtectedTag`
+ :class:`gitlab.v4.objects.ProjectProtectedTagManager`
+ :attr:`gitlab.v4.objects.Project.protectedtags`

* GitLab API: https://docs.gitlab.com/ce/api/protected_tags.html

Examples
---------

Get a list of protected tags from a project::

protected_tags = project.protectedtags.list()

Get a single protected tag or wildcard protected tag::

protected_tag = project.protectedtags.get('v*')
max-wittig marked this conversation as resolved.
Show resolved Hide resolved

Protect a single repository tag or several project repository tags using a wildcard protected tag::

project.protectedtags.create({'name': 'v*', 'create_access_level': '40'})

Unprotect the given protected tag or wildcard protected tag.::

protected_tag.delete()
13 changes: 13 additions & 0 deletions gitlab/v4/objects.py
Expand Up @@ -1965,6 +1965,18 @@ class ProjectTagManager(NoUpdateMixin, RESTManager):
_create_attrs = (('tag_name', 'ref'), ('message',))


class ProjectProtectedTag(ObjectDeleteMixin, RESTObject):
_id_attr = 'name'
_short_print_attr = 'name'


class ProjectProtectedTagManager(NoUpdateMixin, RESTManager):
_path = '/projects/%(project_id)s/protected_tags'
_obj_cls = ProjectProtectedTag
_from_parent_attrs = {'project_id': 'id'}
_create_attrs = (('name',), ('create_access_level',))


class ProjectMergeRequestApproval(SaveMixin, RESTObject):
_id_attr = None

Expand Down Expand Up @@ -3124,6 +3136,7 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
('pagesdomains', 'ProjectPagesDomainManager'),
('pipelines', 'ProjectPipelineManager'),
('protectedbranches', 'ProjectProtectedBranchManager'),
('protectedtags', 'ProjectProtectedTagManager'),
('pipelineschedules', 'ProjectPipelineScheduleManager'),
('pushrules', 'ProjectPushRulesManager'),
('runners', 'ProjectRunnerManager'),
Expand Down