4
4
# #
5
5
# Copyright 2020 Steve Kowalik <[email protected] > #
6
6
# Copyright 2020 Colby Gallup <[email protected] > #
7
+ # Copyright 2020 Pascal Hofmann <[email protected] > #
7
8
# #
8
9
# This file is part of PyGithub. #
9
10
# http://pygithub.readthedocs.io/ #
@@ -92,6 +93,22 @@ def environment(self):
92
93
self ._completeIfNotSet (self ._environment )
93
94
return self ._environment .value
94
95
96
+ @property
97
+ def production_environment (self ):
98
+ """
99
+ :type: bool
100
+ """
101
+ self ._completeIfNotSet (self ._production_environment )
102
+ return self ._production_environment .value
103
+
104
+ @property
105
+ def transient_environment (self ):
106
+ """
107
+ :type: bool
108
+ """
109
+ self ._completeIfNotSet (self ._transient_environment )
110
+ return self ._transient_environment .value
111
+
95
112
@property
96
113
def description (self ):
97
114
"""
@@ -150,6 +167,7 @@ def get_statuses(self):
150
167
self ._requester ,
151
168
self .url + "/statuses" ,
152
169
None ,
170
+ headers = {"Accept" : self ._get_accept_header ()},
153
171
)
154
172
155
173
def get_status (self , id_ ):
@@ -162,7 +180,7 @@ def get_status(self, id_):
162
180
headers , data = self ._requester .requestJsonAndCheck (
163
181
"GET" ,
164
182
self .url + "/statuses/" + str (id_ ),
165
- headers = {"Accept" : github . Consts . deploymentEnhancementsPreview },
183
+ headers = {"Accept" : self . _get_accept_header () },
166
184
)
167
185
return github .DeploymentStatus .DeploymentStatus (
168
186
self ._requester , headers , data , completed = True
@@ -173,12 +191,18 @@ def create_status(
173
191
state ,
174
192
target_url = github .GithubObject .NotSet ,
175
193
description = github .GithubObject .NotSet ,
194
+ environment = github .GithubObject .NotSet ,
195
+ environment_url = github .GithubObject .NotSet ,
196
+ auto_inactive = github .GithubObject .NotSet ,
176
197
):
177
198
"""
178
199
:calls: `POST /repos/:owner/:repo/deployments/:deployment_id/statuses <https://developer.github.com/v3/repos/deployments/#create-a-deployment-status>`_
179
200
:param: state: string
180
201
:param: target_url: string
181
202
:param: description: string
203
+ :param: environment: string
204
+ :param: environment_url: string
205
+ :param: auto_inactive: bool
182
206
:rtype: :class:`github.DeploymentStatus.DeploymentStatus`
183
207
"""
184
208
assert isinstance (state , str ), state
@@ -187,23 +211,52 @@ def create_status(
187
211
), target_url
188
212
assert description is github .GithubObject .NotSet or isinstance (
189
213
description , str
190
- ), target_url
214
+ ), description
215
+ assert environment is github .GithubObject .NotSet or isinstance (
216
+ environment , str
217
+ ), environment
218
+ assert environment_url is github .GithubObject .NotSet or isinstance (
219
+ environment_url , str
220
+ ), environment_url
221
+ assert auto_inactive is github .GithubObject .NotSet or isinstance (
222
+ auto_inactive , bool
223
+ ), auto_inactive
224
+
191
225
post_parameters = {"state" : state }
192
226
if target_url is not github .GithubObject .NotSet :
193
227
post_parameters ["target_url" ] = target_url
194
228
if description is not github .GithubObject .NotSet :
195
229
post_parameters ["description" ] = description
230
+ if environment is not github .GithubObject .NotSet :
231
+ post_parameters ["environment" ] = environment
232
+ if environment_url is not github .GithubObject .NotSet :
233
+ post_parameters ["environment_url" ] = environment_url
234
+ if auto_inactive is not github .GithubObject .NotSet :
235
+ post_parameters ["auto_inactive" ] = auto_inactive
236
+
196
237
headers , data = self ._requester .requestJsonAndCheck (
197
238
"POST" ,
198
239
self .url + "/statuses" ,
199
240
input = post_parameters ,
241
+ headers = {"Accept" : self ._get_accept_header ()},
200
242
)
201
243
return github .DeploymentStatus .DeploymentStatus (
202
244
self ._requester , headers , data , completed = True
203
245
)
204
246
247
+ @staticmethod
248
+ def _get_accept_header ():
249
+ return ", " .join (
250
+ [
251
+ github .Consts .deploymentEnhancementsPreview ,
252
+ github .Consts .deploymentStatusEnhancementsPreview ,
253
+ ]
254
+ )
255
+
205
256
def _initAttributes (self ):
206
257
self ._id = github .GithubObject .NotSet
258
+ self ._production_environment = github .GithubObject .NotSet
259
+ self ._transient_environment = github .GithubObject .NotSet
207
260
self ._url = github .GithubObject .NotSet
208
261
self ._sha = github .GithubObject .NotSet
209
262
self ._task = github .GithubObject .NotSet
@@ -220,6 +273,14 @@ def _initAttributes(self):
220
273
def _useAttributes (self , attributes ):
221
274
if "id" in attributes : # pragma no branch
222
275
self ._id = self ._makeIntAttribute (attributes ["id" ])
276
+ if "production_environment" in attributes : # pragma no branch
277
+ self ._production_environment = self ._makeBoolAttribute (
278
+ attributes ["production_environment" ]
279
+ )
280
+ if "transient_environment" in attributes : # pragma no branch
281
+ self ._transient_environment = self ._makeBoolAttribute (
282
+ attributes ["transient_environment" ]
283
+ )
223
284
if "url" in attributes : # pragma no branch
224
285
self ._url = self ._makeStringAttribute (attributes ["url" ])
225
286
if "sha" in attributes : # pragma no branch
0 commit comments