Skip to content

Commit

Permalink
Add archive and unarchive pipeline endpoints (#84)
Browse files Browse the repository at this point in the history
* Add archive and unarchive endpoints

* Use double quotes to match style

* Add tests for archive and unarchive

* Fix test path formatting

* Fix test URL formatting
  • Loading branch information
fd-jonathanlinn committed Jan 13, 2023
1 parent 68359f6 commit 173b09d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
24 changes: 22 additions & 2 deletions pybuildkite/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def delete_pipeline(self, organization, pipeline):
"""
url = self.path.format(organization) + pipeline
return self.client.delete(url)

def update_pipeline(
self,
organization,
Expand Down Expand Up @@ -184,7 +184,27 @@ def update_pipeline(
}
url = self.path.format(organization) + pipeline
return self.client.patch(url, body=body)


def archive_pipeline(self, organization, pipeline):
"""
Archive a pipeline
:param organization: Organization slug
:param pipeline: Pipeline slug
:return:
"""
url = self.path.format(organization) + pipeline + "/archive"
return self.client.post(url)

def unarchive_pipeline(self, organization, pipeline):
"""
Unarchive a pipeline
:param organization: Organization slug
:param pipeline: Pipeline slug
:return:
"""
url = self.path.format(organization) + pipeline + "/unarchive"
return self.client.post(url)


class PipelineException(Exception):
pass
18 changes: 18 additions & 0 deletions tests/test_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,21 @@ def test_update_pipeline_configuration_and_steps(fake_client):
configuration="",
steps={},
)

def test_archive_pipeline(fake_client):
pipeline = Pipelines(fake_client, "https://api.buildkite.com/v2/")
pipeline.archive_pipeline(
"test_org", "test_pipeline"
)
fake_client.post.assert_called_with(
pipeline.path.format("test_org") + "test_pipeline" + "/archive"
)

def test_unarchive_pipeline(fake_client):
pipeline = Pipelines(fake_client, "https://api.buildkite.com/v2/")
pipeline.unarchive_pipeline(
"test_org", "test_pipeline"
)
fake_client.post.assert_called_with(
pipeline.path.format("test_org") + "test_pipeline" + "/unarchive"
)

0 comments on commit 173b09d

Please sign in to comment.