semaphoreui-client 0.1.5__py3-none-any.whl → 0.1.6__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.5"
1
+ __version__ = "0.1.6"
@@ -1 +1 @@
1
- from .client import SemaphoreUIClient as Client # NOQA
1
+ from .client import SemaphoreUIClient as Client # NOQA
@@ -6,8 +6,7 @@ import requests
6
6
 
7
7
 
8
8
  class SemaphoreUIClient:
9
-
10
- def __init__(self, host: str, path: str="/api"):
9
+ def __init__(self, host: str, path: str = "/api"):
11
10
  self.http = requests.Session()
12
11
  if host.endswith("/"):
13
12
  host = host.strip("/")
@@ -15,7 +14,7 @@ class SemaphoreUIClient:
15
14
  path = f"/{path}"
16
15
  self.api_endpoint = f"{host}{path}"
17
16
 
18
- def login(self, user, password):
17
+ def login(self, user: str, password: str) -> None:
19
18
  response = self.http.post(
20
19
  f"{self.api_endpoint}/auth/login", json={"auth": user, "password": password}
21
20
  )
@@ -24,13 +23,13 @@ class SemaphoreUIClient:
24
23
  f"Username and/or password incorrect. Response from POST /auth/login was {response.status_code}"
25
24
  )
26
25
 
27
- def whoami(self):
26
+ def whoami(self) -> None:
28
27
  response = self.http.get(f"{self.api_endpoint}/auth/login")
29
- assert (
30
- response.status_code == 200
31
- ), f"GET /auth/login return response {response.status_code}"
28
+ assert response.status_code == 200, (
29
+ f"GET /auth/login return response {response.status_code}"
30
+ )
32
31
 
33
- def logout(self):
32
+ def logout(self) -> None:
34
33
  response = self.http.post(f"{self.api_endpoint}/auth/logout")
35
34
  assert response.status_code == 204
36
35
 
@@ -44,7 +43,7 @@ class SemaphoreUIClient:
44
43
  assert response.status_code == 201
45
44
  return Token(**response.json(), client=self)
46
45
 
47
- def delete_token(self, id):
46
+ def delete_token(self, id: str) -> None:
48
47
  response = self.http.delete(f"{self.api_endpoint}/user/tokens/{id}")
49
48
  assert response.status_code in (204, 404) # 404 if token was already expired
50
49
 
@@ -81,7 +80,7 @@ class SemaphoreUIClient:
81
80
  assert response.status_code == 201
82
81
  return Project(**response.json(), client=self)
83
82
 
84
- def delete_project(self, id: int):
83
+ def delete_project(self, id: int) -> None:
85
84
  response = self.http.delete(f"{self.api_endpoint}/project/{id}")
86
85
  assert response.status_code == 204
87
86
 
@@ -92,8 +91,8 @@ class SemaphoreUIClient:
92
91
  alert: bool,
93
92
  alert_chat: str,
94
93
  max_parallel_tasks: int,
95
- type: typing.Optional[str]=None,
96
- ):
94
+ type: typing.Optional[str] = None,
95
+ ) -> None:
97
96
  response = self.http.put(
98
97
  f"{self.api_endpoint}/project/{id}",
99
98
  json={
@@ -126,19 +125,21 @@ class SemaphoreUIClient:
126
125
  assert response.status_code == 200
127
126
  return [User(**data) for data in response.json()]
128
127
 
129
- def add_project_user(self, id: int, user: "User"):
128
+ def add_project_user(self, id: int, user: "User") -> None:
130
129
  response = self.http.post(
131
- f"{self.api_endpoint}/project/{id}/users", json=user.to_json() # type: ignore
130
+ f"{self.api_endpoint}/project/{id}/users",
131
+ json=user.to_json(), # type: ignore
132
132
  )
133
133
  assert response.status_code == 204
134
134
 
135
- def update_project_user(self, id: int, user: "User"):
135
+ def update_project_user(self, id: int, user: "User") -> None:
136
136
  response = self.http.put(
137
- f"{self.api_endpoint}/project/{id}/users/{user.id}", json=user.to_json() # type: ignore
137
+ f"{self.api_endpoint}/project/{id}/users/{user.id}",
138
+ json=user.to_json(), # type: ignore
138
139
  )
139
140
  assert response.status_code == 204
140
141
 
141
- def remove_project_user(self, id: int, user_id: int):
142
+ def remove_project_user(self, id: int, user_id: int) -> None:
142
143
  response = self.http.delete(f"{self.api_endpoint}/project/{id}/users/{user_id}")
143
144
  assert response.status_code == 204
144
145
 
@@ -159,14 +160,14 @@ class SemaphoreUIClient:
159
160
 
160
161
  def update_project_integration(
161
162
  self, project_id: int, id: int, name: str, template_id: int
162
- ):
163
+ ) -> None:
163
164
  response = self.http.put(
164
165
  f"{self.api_endpoint}/project/{project_id}/integrations/{id}",
165
166
  json={"project_id": project_id, "name": name, "template_id": template_id},
166
167
  )
167
168
  assert response.status_code == 204
168
169
 
169
- def delete_project_integration(self, project_id: int, id: int):
170
+ def delete_project_integration(self, project_id: int, id: int) -> None:
170
171
  response = self.http.delete(
171
172
  f"{self.api_endpoint}/project/{project_id}/integrations/{id}"
172
173
  )
@@ -245,7 +246,7 @@ class SemaphoreUIClient:
245
246
  key for key in self.get_project_keys(project_id) if key.name == name
246
247
  ][0]
247
248
 
248
- def delete_project_key(self, project_id: int, id: int):
249
+ def delete_project_key(self, project_id: int, id: int) -> None:
249
250
  response = self.http.delete(
250
251
  f"{self.api_endpoint}/project/{project_id}/keys/{id}"
251
252
  )
@@ -281,7 +282,7 @@ class SemaphoreUIClient:
281
282
  if repo.name == name
282
283
  ][0]
283
284
 
284
- def delete_project_repository(self, project_id: int, id: int):
285
+ def delete_project_repository(self, project_id: int, id: int) -> None:
285
286
  response = self.http.delete(
286
287
  f"{self.api_endpoint}/project/{project_id}/repositories/{id}"
287
288
  )
@@ -324,7 +325,7 @@ class SemaphoreUIClient:
324
325
  if env.name == name
325
326
  ][0]
326
327
 
327
- def delete_project_environment(self, project_id: int, id: int):
328
+ def delete_project_environment(self, project_id: int, id: int) -> None:
328
329
  response = self.http.delete(
329
330
  f"{self.api_endpoint}/project/{project_id}/environment/{id}"
330
331
  )
@@ -343,7 +344,7 @@ class SemaphoreUIClient:
343
344
  assert response.status_code == 201
344
345
  return View(**response.json(), client=self)
345
346
 
346
- def delete_project_view(self, project_id: int, id: int):
347
+ def delete_project_view(self, project_id: int, id: int) -> None:
347
348
  response = self.http.delete(
348
349
  f"{self.api_endpoint}/project/{project_id}/views/{id}"
349
350
  )
@@ -380,7 +381,7 @@ class SemaphoreUIClient:
380
381
  assert response.status_code == 201
381
382
  return Inventory(**response.json(), client=self)
382
383
 
383
- def delete_project_inventory(self, project_id: int, id: int):
384
+ def delete_project_inventory(self, project_id: int, id: int) -> None:
384
385
  response = self.http.delete(
385
386
  f"{self.api_endpoint}/project/{project_id}/inventory/{id}"
386
387
  )
@@ -440,12 +441,12 @@ class SemaphoreUIClient:
440
441
  "autorun": autorun,
441
442
  },
442
443
  )
443
- assert (
444
- response.status_code == 201
445
- ), f"Expected response code 201, got {response.status_code}"
444
+ assert response.status_code == 201, (
445
+ f"Expected response code 201, got {response.status_code}"
446
+ )
446
447
  return Template(**response.json(), client=self)
447
448
 
448
- def delete_project_template(self, project_id: int, id: int):
449
+ def delete_project_template(self, project_id: int, id: int) -> None:
449
450
  response = self.http.delete(
450
451
  f"{self.api_endpoint}/project/{project_id}/templates/{id}"
451
452
  )
@@ -463,7 +464,7 @@ class SemaphoreUIClient:
463
464
  name: str,
464
465
  cron_format: str,
465
466
  active: bool = True,
466
- ):
467
+ ) -> "Schedule":
467
468
  response = self.http.post(
468
469
  f"{self.api_endpoint}/project/{project_id}/schedules",
469
470
  json={
@@ -486,7 +487,7 @@ class SemaphoreUIClient:
486
487
  name: str,
487
488
  cron_format: str,
488
489
  active: bool,
489
- ):
490
+ ) -> None:
490
491
  response = self.http.post(
491
492
  f"{self.api_endpoint}/project/{project_id}/schedules",
492
493
  json={
@@ -499,9 +500,8 @@ class SemaphoreUIClient:
499
500
  },
500
501
  )
501
502
  assert response.status_code == 201
502
- return Schedule(**response.json(), client=self)
503
503
 
504
- def delete_project_schedule(self, project_id: int, schedule_id: int):
504
+ def delete_project_schedule(self, project_id: int, schedule_id: int) -> None:
505
505
  response = self.http.delete(
506
506
  f"{self.api_endpoint}/project/{project_id}/schedules/{schedule_id}"
507
507
  )
@@ -519,12 +519,12 @@ class Integration:
519
519
 
520
520
  client: SemaphoreUIClient
521
521
 
522
- def save(self):
522
+ def save(self) -> None:
523
523
  self.client.update_project_integration(
524
524
  self.project_id, self.id, self.name, self.template_id
525
525
  )
526
526
 
527
- def delete(self):
527
+ def delete(self) -> None:
528
528
  self.client.delete_project_integration(self.project_id, self.id)
529
529
 
530
530
 
@@ -539,7 +539,7 @@ class Token:
539
539
 
540
540
  client: SemaphoreUIClient
541
541
 
542
- def delete(self):
542
+ def delete(self) -> None:
543
543
  self.client.delete_token(self.id)
544
544
 
545
545
 
@@ -557,10 +557,10 @@ class Project:
557
557
 
558
558
  client: SemaphoreUIClient
559
559
 
560
- def delete(self):
560
+ def delete(self) -> None:
561
561
  self.client.delete_project(self.id)
562
562
 
563
- def save(self):
563
+ def save(self) -> None:
564
564
  self.client.update_project(
565
565
  self.id,
566
566
  self.name,
@@ -570,25 +570,25 @@ class Project:
570
570
  self.type,
571
571
  )
572
572
 
573
- def backup(self):
573
+ def backup(self) -> "ProjectBackup":
574
574
  return self.client.backup_project(self.id)
575
575
 
576
- def role(self):
576
+ def role(self) -> "Permissions":
577
577
  return self.client.get_project_role(self.id)
578
578
 
579
- def events(self):
579
+ def events(self) -> typing.List["Event"]:
580
580
  return self.client.get_project_events(self.id)
581
581
 
582
- def users(self, sort: str, order: str):
582
+ def users(self, sort: str, order: str) -> typing.List["User"]:
583
583
  return self.client.get_project_users(self.id, sort, order)
584
584
 
585
- def add_user(self, user: "User"):
585
+ def add_user(self, user: "User") -> None:
586
586
  return self.client.add_project_user(self.id, user)
587
587
 
588
- def remove_user(self, user_id: int):
588
+ def remove_user(self, user_id: int) -> None:
589
589
  return self.client.remove_project_user(self.id, user_id)
590
590
 
591
- def update_user(self, user: "User"):
591
+ def update_user(self, user: "User") -> None:
592
592
  return self.client.update_project_user(self.id, user)
593
593
 
594
594
  def keys(self) -> typing.List["Key"]:
@@ -601,7 +601,7 @@ class Project:
601
601
  override_secret: bool = False,
602
602
  login_password: typing.Optional[typing.Tuple[str, str]] = None,
603
603
  ssh: typing.Optional[typing.Tuple[str, str, str]] = None,
604
- ):
604
+ ) -> "Key":
605
605
  return self.client.create_project_key(
606
606
  self.id, name, key_type, override_secret, login_password, ssh
607
607
  )
@@ -769,22 +769,7 @@ class Key:
769
769
 
770
770
  client: SemaphoreUIClient
771
771
 
772
- @classmethod
773
- def from_dict(cls, **keys) -> "Key":
774
- ssh = KeySsh(
775
- login=keys["ssh"]["login"],
776
- passphrase=keys["ssh"]["passphrase"],
777
- private_key=keys["ssh"]["private_key"],
778
- )
779
- login_password = KeyLoginPassword(
780
- login=keys["login_password"]["login"],
781
- password=keys["login_password"]["password"],
782
- )
783
- del keys["ssh"]
784
- del keys["login_password"]
785
- return cls(**keys, ssh=ssh, login_password=login_password)
786
-
787
- def delete(self):
772
+ def delete(self) -> None:
788
773
  self.client.delete_project_key(self.project_id, self.id)
789
774
 
790
775
 
@@ -799,7 +784,7 @@ class Repository:
799
784
 
800
785
  client: SemaphoreUIClient
801
786
 
802
- def delete(self):
787
+ def delete(self) -> None:
803
788
  self.client.delete_project_repository(self.project_id, self.id)
804
789
 
805
790
 
@@ -822,7 +807,7 @@ class Environment:
822
807
 
823
808
  client: SemaphoreUIClient
824
809
 
825
- def delete(self):
810
+ def delete(self) -> None:
826
811
  self.client.delete_project_environment(self.project_id, self.id)
827
812
 
828
813
 
@@ -835,7 +820,7 @@ class View:
835
820
 
836
821
  client: SemaphoreUIClient
837
822
 
838
- def delete(self):
823
+ def delete(self) -> None:
839
824
  self.client.delete_project_view(self.project_id, self.id)
840
825
 
841
826
 
@@ -854,7 +839,7 @@ class Inventory:
854
839
 
855
840
  client: SemaphoreUIClient
856
841
 
857
- def delete(self):
842
+ def delete(self) -> None:
858
843
  self.client.delete_project_inventory(self.project_id, self.id)
859
844
 
860
845
 
@@ -884,7 +869,7 @@ class Template:
884
869
 
885
870
  client: SemaphoreUIClient
886
871
 
887
- def delete(self):
872
+ def delete(self) -> None:
888
873
  self.client.delete_project_template(self.project_id, self.id)
889
874
 
890
875
 
@@ -900,7 +885,7 @@ class Schedule:
900
885
 
901
886
  client: SemaphoreUIClient
902
887
 
903
- def save(self):
888
+ def save(self) -> None:
904
889
  self.client.update_project_schedule(
905
890
  self.project_id,
906
891
  self.id,
@@ -910,5 +895,5 @@ class Schedule:
910
895
  self.active,
911
896
  )
912
897
 
913
- def delete(self):
898
+ def delete(self) -> None:
914
899
  self.client.delete_project_schedule(self.project_id, self.id)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: semaphoreui-client
3
- Version: 0.1.5
3
+ Version: 0.1.6
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=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,,
@@ -1,6 +0,0 @@
1
- semaphoreui_client/__about__.py,sha256=Nmswip0IUvJenHIhdfSyTYurDcwWTvOQ8mPDREtwE1o,21
2
- semaphoreui_client/__init__.py,sha256=r2j1tTgwFzp3AKAktr8izDIXllRf-Y0SdHAjInYDTP0,55
3
- semaphoreui_client/client.py,sha256=qmgpWfrZS-NRO6jUeOCnjQg1bsyP0lRpih9VKItEciw,27809
4
- semaphoreui_client-0.1.5.dist-info/METADATA,sha256=hbHoE7wjYnzfgjTH_3FqXo1RT3pdUpoE0Z6qdUJ6-wc,1632
5
- semaphoreui_client-0.1.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
- semaphoreui_client-0.1.5.dist-info/RECORD,,