semaphoreui-client 0.1.15__tar.gz → 0.1.17__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: semaphoreui-client
3
- Version: 0.1.15
3
+ Version: 0.1.17
4
4
  Summary: An api client for interacting with Semaphore UI
5
5
  Project-URL: Documentation, https://github.com/rockstar/semaphoreui-client#readme
6
6
  Project-URL: Issues, https://github.com/rockstar/semaphoreui-client/issues
@@ -0,0 +1 @@
1
+ __version__ = "0.1.17"
@@ -451,6 +451,37 @@ class SemaphoreUIClient:
451
451
  )
452
452
  return Template(**response.json(), client=self)
453
453
 
454
+ def run_template(
455
+ self,
456
+ template_id: int,
457
+ project_id: int,
458
+ debug: bool,
459
+ dry_run: bool,
460
+ diff: bool,
461
+ message: str,
462
+ git_branch: str,
463
+ limit: str,
464
+ environment: str,
465
+ playbook: str,
466
+ ) -> "Task":
467
+ response = self.http.post(
468
+ f"{self.api_endpoint}/project/{project_id}/tasks",
469
+ json={
470
+ "template_id": template_id,
471
+ "debug": debug,
472
+ "dry_run": dry_run,
473
+ "diff": diff,
474
+ "playbook": playbook,
475
+ "environment": environment,
476
+ "limit": limit,
477
+ "git_branch": git_branch,
478
+ "message": message,
479
+ },
480
+ )
481
+ assert response.status_code == 201
482
+ # The response is not quite a full task, so re-fetch it.
483
+ return self.get_project_task(project_id, response.json()["id"])
484
+
454
485
  def delete_project_template(self, project_id: int, id: int) -> None:
455
486
  response = self.http.delete(
456
487
  f"{self.api_endpoint}/project/{project_id}/templates/{id}"
@@ -526,7 +557,7 @@ class SemaphoreUIClient:
526
557
  def get_project_task(self, project_id: int, id: int) -> "Task":
527
558
  response = self.http.get(f"{self.api_endpoint}/project/{project_id}/tasks/{id}")
528
559
  assert response.status_code == 200
529
- return Task(**response.json(), project_id=project_id, client=self)
560
+ return Task(**response.json(), client=self)
530
561
 
531
562
  def delete_project_task(self, project_id: int, id: int) -> None:
532
563
  response = self.http.delete(
@@ -909,6 +940,34 @@ class Template:
909
940
 
910
941
  client: SemaphoreUIClient
911
942
 
943
+ def run(
944
+ self,
945
+ debug: bool = False,
946
+ dry_run: bool = False,
947
+ diff: bool = False,
948
+ message: str = "",
949
+ limit: str = "",
950
+ environment: str = "",
951
+ ) -> "Task":
952
+ repo = [
953
+ repo
954
+ for repo in self.client.get_project_repositories(self.project_id)
955
+ if repo.id == self.repository_id
956
+ ][0]
957
+ git_branch = repo.git_branch
958
+ return self.client.run_template(
959
+ self.id,
960
+ self.project_id,
961
+ debug,
962
+ dry_run,
963
+ diff,
964
+ message,
965
+ git_branch,
966
+ limit,
967
+ environment,
968
+ self.playbook,
969
+ )
970
+
912
971
  def delete(self) -> None:
913
972
  self.client.delete_project_template(self.project_id, self.id)
914
973
 
@@ -1 +0,0 @@
1
- __version__ = "0.1.15"