|
| 1 | +""" |
| 2 | +GitLab API: |
| 3 | +https://docs.gitlab.com/ee/api/instance_level_ci_variables.html |
| 4 | +https://docs.gitlab.com/ee/api/project_level_variables.html |
| 5 | +https://docs.gitlab.com/ee/api/group_level_variables.html |
| 6 | +""" |
| 7 | +from gitlab.base import * # noqa |
| 8 | +from gitlab.mixins import * # noqa |
| 9 | + |
| 10 | + |
| 11 | +class Variable(SaveMixin, ObjectDeleteMixin, RESTObject): |
| 12 | + _id_attr = "key" |
| 13 | + |
| 14 | + |
| 15 | +class VariableManager(CRUDMixin, RESTManager): |
| 16 | + _path = "/admin/ci/variables" |
| 17 | + _obj_cls = Variable |
| 18 | + _create_attrs = (("key", "value"), ("protected", "variable_type", "masked")) |
| 19 | + _update_attrs = (("key", "value"), ("protected", "variable_type", "masked")) |
| 20 | + |
| 21 | + |
| 22 | +class GroupVariable(SaveMixin, ObjectDeleteMixin, RESTObject): |
| 23 | + _id_attr = "key" |
| 24 | + |
| 25 | + |
| 26 | +class GroupVariableManager(CRUDMixin, RESTManager): |
| 27 | + _path = "/groups/%(group_id)s/variables" |
| 28 | + _obj_cls = GroupVariable |
| 29 | + _from_parent_attrs = {"group_id": "id"} |
| 30 | + _create_attrs = (("key", "value"), ("protected", "variable_type", "masked")) |
| 31 | + _update_attrs = (("key", "value"), ("protected", "variable_type", "masked")) |
| 32 | + |
| 33 | + |
| 34 | +class ProjectVariable(SaveMixin, ObjectDeleteMixin, RESTObject): |
| 35 | + _id_attr = "key" |
| 36 | + |
| 37 | + |
| 38 | +class ProjectVariableManager(CRUDMixin, RESTManager): |
| 39 | + _path = "/projects/%(project_id)s/variables" |
| 40 | + _obj_cls = ProjectVariable |
| 41 | + _from_parent_attrs = {"project_id": "id"} |
| 42 | + _create_attrs = ( |
| 43 | + ("key", "value"), |
| 44 | + ("protected", "variable_type", "masked", "environment_scope"), |
| 45 | + ) |
| 46 | + _update_attrs = ( |
| 47 | + ("key", "value"), |
| 48 | + ("protected", "variable_type", "masked", "environment_scope"), |
| 49 | + ) |
0 commit comments