summaryrefslogtreecommitdiff
path: root/gitlab/v4/objects/environments.py
diff options
context:
space:
mode:
authorcalve <calvinh34@gmail.com>2022-06-21 16:41:45 +0200
committercalve <calvinh34@gmail.com>2022-06-22 15:17:41 +0200
commit1dc9d0f91757eed9f28f0c7172654b9b2a730216 (patch)
tree0a1f3b1e479892e7149e6d0c00c9f3c6245ad4f0 /gitlab/v4/objects/environments.py
parent8342f53854c0accf5bc8ce9a9be64a5f335eed07 (diff)
downloadgitlab-1dc9d0f91757eed9f28f0c7172654b9b2a730216.tar.gz
feat: Add support for Protected Environments
- https://docs.gitlab.com/ee/api/protected_environments.html - https://github.com/python-gitlab/python-gitlab/issues/1130 no write operation are implemented yet as I have no use case right now and am not sure how it should be done
Diffstat (limited to 'gitlab/v4/objects/environments.py')
-rw-r--r--gitlab/v4/objects/environments.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/gitlab/v4/objects/environments.py b/gitlab/v4/objects/environments.py
index 7e2089f..a8bd9d5 100644
--- a/gitlab/v4/objects/environments.py
+++ b/gitlab/v4/objects/environments.py
@@ -18,6 +18,8 @@ from gitlab.types import RequiredOptional
__all__ = [
"ProjectEnvironment",
"ProjectEnvironmentManager",
+ "ProjectProtectedEnvironment",
+ "ProjectProtectedEnvironmentManager",
]
@@ -55,3 +57,30 @@ class ProjectEnvironmentManager(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
) -> ProjectEnvironment:
return cast(ProjectEnvironment, super().get(id=id, lazy=lazy, **kwargs))
+
+
+class ProjectProtectedEnvironment(ObjectDeleteMixin, RESTObject):
+ _id_attr = "name"
+ _repr_attr = "name"
+
+
+class ProjectProtectedEnvironmentManager(
+ RetrieveMixin, CreateMixin, DeleteMixin, RESTManager
+):
+ _path = "/projects/{project_id}/protected_environments"
+ _obj_cls = ProjectProtectedEnvironment
+ _from_parent_attrs = {"project_id": "id"}
+ _create_attrs = RequiredOptional(
+ required=(
+ "name",
+ "deploy_access_levels",
+ ),
+ optional=("required_approval_count", "approval_rules"),
+ )
+
+ def get(
+ self, id: Union[str, int], lazy: bool = False, **kwargs: Any
+ ) -> ProjectProtectedEnvironment:
+ return cast(
+ ProjectProtectedEnvironment, super().get(id=id, lazy=lazy, **kwargs)
+ )