Skip to content

Commit

Permalink
Merge pull request #5 from alpinweis/work
Browse files Browse the repository at this point in the history
bump version
  • Loading branch information
alpinweis authored Aug 1, 2020
2 parents e8fdacb + 08e6678 commit 9de5f65
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### [0.3.1] - 2020-08-01
* Add job approval endpoint (API v2)

### [0.3.0] - 2020-05-24
* Add endpoints to get project pipelines (API v2)
* Add endpoints to get project insights (API v2)
Expand Down
30 changes: 13 additions & 17 deletions pycircleci/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,6 @@ def __repr__(self):
kwargs = [f"{k}={v!r}" for k, v in opts.items()]
return f'Api({", ".join(kwargs)})'

def approve_job(
self,
workflow_id,
approval_request_id
):
"""Approves a pending approval job in a workflow.
:param workflow_id: Workflow ID.
:param approval_request_id: The ID of the job being approved.
Endpoint:
POST ``/workflow/:workflow_id/approve/:approval_request_id``
"""
endpoint = "workflow/{0}/approve/{1}".format(workflow_id, approval_request_id)
resp = self._request(POST, endpoint, api_version=API_VER_V2)
return resp

def get_user_info(self):
"""Get info about the signed in user.
Expand Down Expand Up @@ -430,6 +413,19 @@ def get_workflow_jobs(self, workflow_id):
resp = self._request(GET, endpoint, api_version=API_VER_V2)
return resp

def approve_job(self, workflow_id, approval_request_id):
"""Approves a pending approval job in a workflow.
:param workflow_id: Workflow ID.
:param approval_request_id: The ID of the job being approved.
Endpoint:
POST ``/workflow/:workflow_id/approve/:approval_request_id``
"""
endpoint = "workflow/{0}/approve/{1}".format(workflow_id, approval_request_id)
resp = self._request(POST, endpoint, api_version=API_VER_V2)
return resp

def add_ssh_user(self, username, project, build_num, vcs_type=GITHUB):
"""Adds a user to the build SSH permissions.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup

VERSION = "0.3.0"
VERSION = "0.3.1"

with open("README.md", "r") as f:
long_description = f.read()
Expand Down
12 changes: 6 additions & 6 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ def test_bad_verb(self):

self.assertIn("Invalid verb: BAD", str(e.exception))

def test_approve_job(self):
self.get_mock("approve_job_response")
resp = js(self.c.approve_job("workflow_id", "approval_request_id"))

self.assertEqual(resp["message"], "Accepted.")

def test_get_user_info(self):
self.get_mock("user_info_response")
resp = js(self.c.get_user_info())
Expand Down Expand Up @@ -177,6 +171,12 @@ def test_get_workflow_jobs(self):

self.assertEqual(len(resp["items"]), 2)

def test_approve_job(self):
self.get_mock("approve_job_response")
resp = js(self.c.approve_job("workflow_id", "approval_request_id"))

self.assertEqual(resp["message"], "Accepted.")

def test_list_checkout_keys(self):
self.get_mock("list_checkout_keys_response")
resp = js(self.c.list_checkout_keys("user", "circleci-sandbox"))
Expand Down

0 comments on commit 9de5f65

Please sign in to comment.