File: protected_packages.rst

package info (click to toggle)
python-gitlab 1%3A4.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,048 kB
  • sloc: python: 24,168; makefile: 171; ruby: 27; javascript: 3
file content (44 lines) | stat: -rw-r--r-- 1,090 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
##################
Protected packages
##################

You can list and manage package protection rules in a project.

References
----------

* v4 API:

  + :class:`gitlab.v4.objects.ProjectPackageProtectionRule`
  + :class:`gitlab.v4.objects.ProjectPackageProtectionRuleManager`
  + :attr:`gitlab.v4.objects.Project.package_protection_rules`

* GitLab API: https://docs.gitlab.com/ee/api/project_packages_protection_rules.html

Examples
--------

List the package protection rules for a project::

    package_rules = project.package_protection_rules.list()

Create a package protection rule::

    package_rule = project.package_protection_rules.create(
        {
            'package_name_pattern': 'v*',
            'package_type': 'npm',
            'minimum_access_level_for_push': 'maintainer'
        }
    )

Update a package protection rule::

    package_rule.minimum_access_level_for_push = 'developer'
    package_rule.save()

Delete a package protection rule::

    package_rule = project.package_protection_rules.delete(package_rule.id)
    # or
    package_rule.delete()