From 08e66787b458e420d165d8f3367259d2c2090d3f Mon Sep 17 00:00:00 2001 From: alpinweis Date: Sat, 1 Aug 2020 14:24:25 +0300 Subject: [PATCH] bump version --- CHANGELOG.md | 3 +++ pycircleci/api.py | 30 +++++++++++++----------------- setup.py | 2 +- tests/test_api.py | 12 ++++++------ 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 607d01e..5d8f038 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/pycircleci/api.py b/pycircleci/api.py index af9d4e3..17be992 100644 --- a/pycircleci/api.py +++ b/pycircleci/api.py @@ -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. @@ -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. diff --git a/setup.py b/setup.py index 1d751f7..bf06f1c 100644 --- a/setup.py +++ b/setup.py @@ -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() diff --git a/tests/test_api.py b/tests/test_api.py index 3f604bf..951a99f 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -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()) @@ -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"))