|
12 | 12 |
|
13 | 13 | import uritemplate as urit
|
14 | 14 |
|
| 15 | +from .. import checks |
15 | 16 | from .. import events
|
16 | 17 | from .. import exceptions
|
17 | 18 | from .. import git
|
@@ -263,6 +264,42 @@ def branches(self, number=-1, protected=False, etag=None):
|
263 | 264 | headers=branch.Branch.PREVIEW_HEADERS,
|
264 | 265 | )
|
265 | 266 |
|
| 267 | + @requires_auth |
| 268 | + def check_run(self, id): |
| 269 | + """Return a single check run. |
| 270 | +
|
| 271 | + :param int id: |
| 272 | + (required), id of the check run |
| 273 | + :returns: |
| 274 | + the check run |
| 275 | + :rtype: |
| 276 | + :class:`~github3.checks.CheckRun` |
| 277 | + """ |
| 278 | + data = None |
| 279 | + if int(id) > 0: |
| 280 | + url = self._build_url('check-runs', str(id), |
| 281 | + base_url=self._api) |
| 282 | + data = self._json(self._get(url), 200) |
| 283 | + return self._instance_or_null(checks.CheckRun, data) |
| 284 | + |
| 285 | + @requires_auth |
| 286 | + def check_suite(self, id): |
| 287 | + """Return a single check suite. |
| 288 | +
|
| 289 | + :param int id: |
| 290 | + (required), id of the check suite |
| 291 | + :returns: |
| 292 | + the check suite |
| 293 | + :rtype: |
| 294 | + :class:`~github3.checks.CheckSuite` |
| 295 | + """ |
| 296 | + data = None |
| 297 | + if int(id) > 0: |
| 298 | + url = self._build_url('check-suites', str(id), |
| 299 | + base_url=self._api) |
| 300 | + data = self._json(self._get(url), 200) |
| 301 | + return self._instance_or_null(checks.CheckSuite, data) |
| 302 | + |
266 | 303 | def code_frequency(self, number=-1, etag=None):
|
267 | 304 | """Iterate over the code frequency per week.
|
268 | 305 |
|
@@ -517,6 +554,77 @@ def contributors(self, anon=False, number=-1, etag=None):
|
517 | 554 | params = {"anon": "true"}
|
518 | 555 | return self._iter(int(number), url, users.Contributor, params, etag)
|
519 | 556 |
|
| 557 | + @requires_auth |
| 558 | + def create_check_run(self, name, head_sha, details_url=None, |
| 559 | + external_id=None, started_at=None, status=None, |
| 560 | + conclusion=None, completed_at=None, output=None, |
| 561 | + actions=None): |
| 562 | + """Create a check run object on a commit |
| 563 | +
|
| 564 | + :param str name: |
| 565 | + (required), The name of the check |
| 566 | + :param str head_sha: |
| 567 | + (required), The SHA of the commit |
| 568 | + :param str details_url: |
| 569 | + (optional), The URL of the integrator's site that has the full |
| 570 | + details of the check |
| 571 | + :param str external_id: |
| 572 | + (optional), A reference for the run on the integrator's system |
| 573 | + :param str started_at: |
| 574 | + (optional), ISO 8601 time format: YYYY-MM-DDTHH:MM:SSZ |
| 575 | + :param str status: |
| 576 | + (optional), ('queued', 'in_progress', 'completed') |
| 577 | + :param str conclusion: |
| 578 | + (optional), Required if you provide 'completed_at', or a |
| 579 | + 'status' of 'completed'. The final conclusion of the check. |
| 580 | + ('success', 'failure', 'neutral', 'cancelled', 'timed_out', |
| 581 | + 'action_required') |
| 582 | + :param str completed_at: |
| 583 | + (optional), Required if you provide 'conclusion'. ISO 8601 time |
| 584 | + format: YYYY-MM-DDTHH:MM:SSZ |
| 585 | + :param dict output: |
| 586 | + (optional), key-value pairs representing the output. Format: |
| 587 | + {'title': 'string', 'summary', 'text, can be markdown', 'text': |
| 588 | + 'text, can be markdown', 'annotations': [{}], 'images': [{}]} |
| 589 | + :param array actions: |
| 590 | + (optiona), array of action objects. Object format is: |
| 591 | + {'label': 'text', 'description', 'text', 'identifier', 'text'} |
| 592 | + :returns: |
| 593 | + the created check run |
| 594 | + :rtype: |
| 595 | + :class:`~github3.checks.CheckRun` |
| 596 | + """ |
| 597 | + json = None |
| 598 | + # TODO: Cleanse output dict, actions array |
| 599 | + if name and head_sha: |
| 600 | + data = {'name': name, 'details_url': details_url, 'external_id': |
| 601 | + external_id, 'started_at': started_at, 'status': status, |
| 602 | + 'conclusion': conclusion, 'completed_at': completed_at, |
| 603 | + 'output': output, 'actions': actions} |
| 604 | + self._remove_none(data) |
| 605 | + url = self._build_url('check-runs', base_url=self._api) |
| 606 | + json = self._json(self._post(url, data=data), 201) |
| 607 | + return self._instance_or_null(checks.CheckRun, json) |
| 608 | + |
| 609 | + @requires_auth |
| 610 | + def create_check_suite(self, head_sha): |
| 611 | + """Create a check suite object on a commit |
| 612 | +
|
| 613 | + :param str head_sha: |
| 614 | + The sha of the head commit. |
| 615 | + :returns: |
| 616 | + the created check suite |
| 617 | + :rtype: |
| 618 | + :class:`~github3.checks.CheckSuite` |
| 619 | + """ |
| 620 | + json = None |
| 621 | + if head_sha: |
| 622 | + data = {'head_sha': head_sha} |
| 623 | + self._remove_none(data) |
| 624 | + url = self._build_url('check-suites', base_url=self._api) |
| 625 | + json = self._json(self._post(url, data=data), 201) |
| 626 | + return self._instance_or_null(checks.CheckSuite, json) |
| 627 | + |
520 | 628 | @requires_auth
|
521 | 629 | def create_blob(self, content, encoding):
|
522 | 630 | """Create a blob with ``content``.
|
|
0 commit comments