Skip to content

Commit 169375f

Browse files
committed
feat: Add support to list Protected Environments
- https://docs.gitlab.com/ee/api/protected_environments.html - #1130 no write operation are implemented yet as I have no use case right now and am not sure how it should be done
1 parent 8342f53 commit 169375f

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

gitlab/v4/objects/environments.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
__all__ = [
1919
"ProjectEnvironment",
2020
"ProjectEnvironmentManager",
21+
"ProjectProtectedEnvironment",
22+
"ProjectProtectedEnvironmentManager",
2123
]
2224

2325

@@ -55,3 +57,26 @@ def get(
5557
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
5658
) -> ProjectEnvironment:
5759
return cast(ProjectEnvironment, super().get(id=id, lazy=lazy, **kwargs))
60+
61+
62+
class ProjectProtectedEnvironment(ObjectDeleteMixin, RESTObject):
63+
_id_attr = "name"
64+
_repr_attr = "name"
65+
66+
67+
class ProjectProtectedEnvironmentManager(
68+
RetrieveMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager
69+
):
70+
_path = "/projects/{project_id}/protected_environments"
71+
_obj_cls = ProjectProtectedEnvironment
72+
_from_parent_attrs = {"project_id": "id"}
73+
_create_attrs = RequiredOptional(required=("name",), optional=("external_url",))
74+
_update_attrs = RequiredOptional(optional=("name", "external_url"))
75+
_list_filters = ("name", "search", "states")
76+
77+
def get(
78+
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
79+
) -> ProjectProtectedEnvironment:
80+
return cast(
81+
ProjectProtectedEnvironment, super().get(id=id, lazy=lazy, **kwargs)
82+
)

gitlab/v4/objects/projects.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
from .deploy_keys import ProjectKeyManager # noqa: F401
3232
from .deploy_tokens import ProjectDeployTokenManager # noqa: F401
3333
from .deployments import ProjectDeploymentManager # noqa: F401
34-
from .environments import ProjectEnvironmentManager # noqa: F401
34+
from .environments import ( # noqa: F401
35+
ProjectEnvironmentManager,
36+
ProjectProtectedEnvironmentManager,
37+
)
3538
from .events import ProjectEventManager # noqa: F401
3639
from .export_import import ProjectExportManager, ProjectImportManager # noqa: F401
3740
from .files import ProjectFileManager # noqa: F401
@@ -175,6 +178,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
175178
pagesdomains: ProjectPagesDomainManager
176179
pipelines: ProjectPipelineManager
177180
pipelineschedules: ProjectPipelineScheduleManager
181+
protectedenvironments: ProjectProtectedEnvironmentManager
178182
protectedbranches: ProjectProtectedBranchManager
179183
protectedtags: ProjectProtectedTagManager
180184
pushrules: ProjectPushRulesManager

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy