FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-gitlab/gitlab/v4/objects/deployments.py at v7.1.0 · python-gitlab/python-gitlab · GitHub
python-gitlab
python-gitlab
Repository navigation
Code
Issues
16
(16)
Pull requests
15
(15)
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-gitlab
/
gitlab
/
v4
/
objects
/
deployments.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
87 lines (72 loc) · 2.67 KB
Breadcrumbs
python-gitlab
/
gitlab
/
v4
/
objects
/
deployments.py
Copy path
File metadata and controls
87 lines (72 loc) · 2.67 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"""
GitLab API:
https://docs.gitlab.com/ee/api/deployments.html
"""
from
__future__
import
annotations
from
typing
import
Any
,
TYPE_CHECKING
from
gitlab
import
cli
from
gitlab
import
exceptions
as
exc
from
gitlab
.
base
import
RESTObject
from
gitlab
.
mixins
import
CreateMixin
,
RetrieveMixin
,
SaveMixin
,
UpdateMixin
from
gitlab
.
types
import
RequiredOptional
from
.
merge_requests
import
ProjectDeploymentMergeRequestManager
# noqa: F401
__all__
=
[
"ProjectDeployment"
,
"ProjectDeploymentManager"
]
class
ProjectDeployment
(
SaveMixin
,
RESTObject
):
mergerequests
:
ProjectDeploymentMergeRequestManager
@
cli
.
register_custom_action
(
cls_names
=
"ProjectDeployment"
,
required
=
(
"status"
,),
optional
=
(
"comment"
,
"represented_as"
),
)
@
exc
.
on_http_error
(
exc
.
GitlabDeploymentApprovalError
)
def
approval
(
self
,
status
:
str
,
comment
:
str
|
None
=
None
,
represented_as
:
str
|
None
=
None
,
**
kwargs
:
Any
,
)
->
dict
[
str
,
Any
]:
"""Approve or reject a blocked deployment.
Args:
status: Either "approved" or "rejected"
comment: A comment to go with the approval
represented_as: The name of the User/Group/Role to use for the
approval, when the user belongs to multiple
approval rules.
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabMRApprovalError: If the approval failed
Returns:
A dict containing the result.
https://docs.gitlab.com/ee/api/deployments.html#approve-or-reject-a-blocked-deployment
"""
path
=
f"
{
self
.
manager
.
path
}
/
{
self
.
encoded_id
}
/approval"
data
=
{
"status"
:
status
}
if
comment
is
not
None
:
data
[
"comment"
]
=
comment
if
represented_as
is
not
None
:
data
[
"represented_as"
]
=
represented_as
server_data
=
self
.
manager
.
gitlab
.
http_post
(
path
,
post_data
=
data
,
**
kwargs
)
if
TYPE_CHECKING
:
assert
isinstance
(
server_data
,
dict
)
return
server_data
class
ProjectDeploymentManager
(
RetrieveMixin
[
ProjectDeployment
],
CreateMixin
[
ProjectDeployment
],
UpdateMixin
[
ProjectDeployment
],
):
_path
=
"/projects/{project_id}/deployments"
_obj_cls
=
ProjectDeployment
_from_parent_attrs
=
{
"project_id"
:
"id"
}
_list_filters
=
(
"order_by"
,
"sort"
,
"updated_after"
,
"updated_before"
,
"environment"
,
"status"
,
)
_create_attrs
=
RequiredOptional
(
required
=
(
"sha"
,
"ref"
,
"tag"
,
"status"
,
"environment"
)
)
Back
|
FazBrowse Home
|
New Git URL