semaphoreui-client 0.1.6__py3-none-any.whl → 0.1.8__py3-none-any.whl

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 +1 @@
1
- __version__ = "0.1.6"
1
+ __version__ = "0.1.8"
@@ -507,6 +507,37 @@ class SemaphoreUIClient:
507
507
  )
508
508
  assert response.status_code == 204
509
509
 
510
+ def get_project_tasks(self, project_id: int) -> typing.List["Task"]:
511
+ response = self.http.get(f"{self.api_endpoint}/project/{project_id}/tasks")
512
+ assert response.status_code == 200
513
+ return [
514
+ Task(**task, project_id=project_id, client=self) for task in response.json()
515
+ ]
516
+
517
+ def stop_project_task(self, project_id: int, id: int) -> None:
518
+ response = self.http.post(
519
+ f"{self.api_endpoint}/project/{project_id}/tasks/{id}/stop"
520
+ )
521
+ assert response.status_code == 204
522
+
523
+ def get_project_task(self, project_id: int, id: int) -> "Task":
524
+ response = self.http.get(f"{self.api_endpoint}/project/{project_id}/tasks/{id}")
525
+ assert response.status_code == 200
526
+ return Task(**response.json(), project_id=project_id, client=self)
527
+
528
+ def delete_project_task(self, project_id: int, id: int) -> None:
529
+ response = self.http.delete(
530
+ f"{self.api_endpoint}/project/{project_id}/tasks/{id}"
531
+ )
532
+ assert response.status_code == 204
533
+
534
+ def get_project_task_output(self, project_id: int, id: int) -> "TaskOutput":
535
+ response = self.http.get(
536
+ f"{self.api_endpoint}/project/{project_id}/tasks/{id}/output"
537
+ )
538
+ assert response.status_code == 200
539
+ return TaskOutput(**response.json())
540
+
510
541
 
511
542
  @dataclass
512
543
  class Integration:
@@ -711,6 +742,12 @@ class Project:
711
742
  self.id, template_id, name, cron_format, active
712
743
  )
713
744
 
745
+ def tasks(self) -> typing.List["Task"]:
746
+ return self.client.get_project_tasks(self.id)
747
+
748
+ def get_task(self, task_id: int) -> "Task":
749
+ return self.client.get_project_task(self.id, task_id)
750
+
714
751
 
715
752
  @dataclass
716
753
  class Permissions:
@@ -897,3 +934,38 @@ class Schedule:
897
934
 
898
935
  def delete(self) -> None:
899
936
  self.client.delete_project_schedule(self.project_id, self.id)
937
+
938
+
939
+ @dataclass
940
+ class Task:
941
+ id: int
942
+ template_id: int
943
+ status: str
944
+ debug: bool
945
+ playbook: str
946
+ environment: str
947
+ secret: str
948
+ limit: str
949
+ git_branch: str
950
+ message: str
951
+
952
+ # Project id isn't included in the api type, but is required
953
+ # to perform operations.
954
+ project_id: int
955
+ client: SemaphoreUIClient
956
+
957
+ def stop(self) -> None:
958
+ self.client.stop_project_task(self.project_id, self.id)
959
+
960
+ def delete(self) -> None:
961
+ self.client.delete_project_task(self.project_id, self.id)
962
+
963
+ def output(self) -> "TaskOutput":
964
+ return self.client.get_project_task_output(self.project_id, self.id)
965
+
966
+
967
+ @dataclass
968
+ class TaskOutput:
969
+ task_id: int
970
+ time: str
971
+ output: str
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: semaphoreui-client
3
- Version: 0.1.6
3
+ Version: 0.1.8
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,6 @@
1
+ semaphoreui_client/__about__.py,sha256=C69ADlbQREQlR15trneyA2sk8x0-oH4rDAX5fsv19_U,22
2
+ semaphoreui_client/__init__.py,sha256=VpeJavEFhs5gyfih7CoRTR4K4IGXGY3UYUkgAWj_f2U,56
3
+ semaphoreui_client/client.py,sha256=54sHBKog_oA0g02B2Vbj-P4NnXvi9wKhbaWgyaY3I8U,29935
4
+ semaphoreui_client-0.1.8.dist-info/METADATA,sha256=JcpU-tA4cn5sQ7a7ptLF6Vt14yAYTGfIGbeCRUsCU_k,1632
5
+ semaphoreui_client-0.1.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
+ semaphoreui_client-0.1.8.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- semaphoreui_client/__about__.py,sha256=n3oM6B_EMz93NsTI18NNZd-jKFcUPzUkbIKj5VFK5ok,22
2
- semaphoreui_client/__init__.py,sha256=VpeJavEFhs5gyfih7CoRTR4K4IGXGY3UYUkgAWj_f2U,56
3
- semaphoreui_client/client.py,sha256=9m_6KJsUHXdSOpE2azhvoaHc0C5uMy-FLuBuyu-oqUM,27663
4
- semaphoreui_client-0.1.6.dist-info/METADATA,sha256=3L2lrUVift904fu4fyPXa7bWocYi2NBQ8oqXGKfyMsY,1632
5
- semaphoreui_client-0.1.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
- semaphoreui_client-0.1.6.dist-info/RECORD,,