Skip to content

Commit bda209a

Browse files
committed
refactor: use parent to access other resources clients
1 parent 3d51af6 commit bda209a

File tree

11 files changed

+80
-80
lines changed

11 files changed

+80
-80
lines changed

hcloud/actions/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def get_by_id(self, id: int) -> BoundAction:
7575
url=f"{self._resource}/actions/{id}",
7676
method="GET",
7777
)
78-
return BoundAction(self._client.actions, response["action"])
78+
return BoundAction(self._parent.actions, response["action"])
7979

8080
def get_list(
8181
self,
@@ -112,7 +112,7 @@ def get_list(
112112
params=params,
113113
)
114114
actions = [
115-
BoundAction(self._client.actions, action_data)
115+
BoundAction(self._parent.actions, action_data)
116116
for action_data in response["actions"]
117117
]
118118
return ActionsPageResult(actions, Meta.parse_meta(response))

hcloud/certificates/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def create_managed(
247247
response = self._client.request(url="/certificates", method="POST", json=data)
248248
return CreateManagedCertificateResponse(
249249
certificate=BoundCertificate(self, response["certificate"]),
250-
action=BoundAction(self._client.actions, response["action"]),
250+
action=BoundAction(self._parent.actions, response["action"]),
251251
)
252252

253253
def update(
@@ -327,7 +327,7 @@ def get_actions_list(
327327
params=params,
328328
)
329329
actions = [
330-
BoundAction(self._client.actions, action_data)
330+
BoundAction(self._parent.actions, action_data)
331331
for action_data in response["actions"]
332332
]
333333
return ActionsPageResult(actions, Meta.parse_meta(response))
@@ -367,4 +367,4 @@ def retry_issuance(
367367
url=f"/certificates/{certificate.id}/actions/retry",
368368
method="POST",
369369
)
370-
return BoundAction(self._client.actions, response["action"])
370+
return BoundAction(self._parent.actions, response["action"])

hcloud/firewalls/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def get_actions_list(
231231
params=params,
232232
)
233233
actions = [
234-
BoundAction(self._client.actions, action_data)
234+
BoundAction(self._parent.actions, action_data)
235235
for action_data in response["actions"]
236236
]
237237
return ActionsPageResult(actions, Meta.parse_meta(response))
@@ -377,7 +377,7 @@ def create(
377377
actions = []
378378
if response.get("actions") is not None:
379379
actions = [
380-
BoundAction(self._client.actions, action_data)
380+
BoundAction(self._parent.actions, action_data)
381381
for action_data in response["actions"]
382382
]
383383

@@ -447,7 +447,7 @@ def set_rules(
447447
json=data,
448448
)
449449
return [
450-
BoundAction(self._client.actions, action_data)
450+
BoundAction(self._parent.actions, action_data)
451451
for action_data in response["actions"]
452452
]
453453

@@ -471,7 +471,7 @@ def apply_to_resources(
471471
json=data,
472472
)
473473
return [
474-
BoundAction(self._client.actions, action_data)
474+
BoundAction(self._parent.actions, action_data)
475475
for action_data in response["actions"]
476476
]
477477

@@ -495,6 +495,6 @@ def remove_from_resources(
495495
json=data,
496496
)
497497
return [
498-
BoundAction(self._client.actions, action_data)
498+
BoundAction(self._parent.actions, action_data)
499499
for action_data in response["actions"]
500500
]

hcloud/floating_ips/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def get_actions_list(
187187
params=params,
188188
)
189189
actions = [
190-
BoundAction(self._client.actions, action_data)
190+
BoundAction(self._parent.actions, action_data)
191191
for action_data in response["actions"]
192192
]
193193
return ActionsPageResult(actions, Meta.parse_meta(response))
@@ -328,7 +328,7 @@ def create(
328328

329329
action = None
330330
if response.get("action") is not None:
331-
action = BoundAction(self._client.actions, response["action"])
331+
action = BoundAction(self._parent.actions, response["action"])
332332

333333
result = CreateFloatingIPResponse(
334334
floating_ip=BoundFloatingIP(self, response["floating_ip"]), action=action
@@ -402,7 +402,7 @@ def change_protection(
402402
method="POST",
403403
json=data,
404404
)
405-
return BoundAction(self._client.actions, response["action"])
405+
return BoundAction(self._parent.actions, response["action"])
406406

407407
def assign(
408408
self,
@@ -421,7 +421,7 @@ def assign(
421421
method="POST",
422422
json={"server": server.id},
423423
)
424-
return BoundAction(self._client.actions, response["action"])
424+
return BoundAction(self._parent.actions, response["action"])
425425

426426
def unassign(self, floating_ip: FloatingIP | BoundFloatingIP) -> BoundAction:
427427
"""Unassigns a Floating IP, resulting in it being unreachable. You may assign it to a server again at a later time.
@@ -433,7 +433,7 @@ def unassign(self, floating_ip: FloatingIP | BoundFloatingIP) -> BoundAction:
433433
url=f"/floating_ips/{floating_ip.id}/actions/unassign",
434434
method="POST",
435435
)
436-
return BoundAction(self._client.actions, response["action"])
436+
return BoundAction(self._parent.actions, response["action"])
437437

438438
def change_dns_ptr(
439439
self,
@@ -455,4 +455,4 @@ def change_dns_ptr(
455455
method="POST",
456456
json={"ip": ip, "dns_ptr": dns_ptr},
457457
)
458-
return BoundAction(self._client.actions, response["action"])
458+
return BoundAction(self._parent.actions, response["action"])

hcloud/images/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def get_actions_list(
160160
params=params,
161161
)
162162
actions = [
163-
BoundAction(self._client.actions, action_data)
163+
BoundAction(self._parent.actions, action_data)
164164
for action_data in response["actions"]
165165
]
166166
return ActionsPageResult(actions, Meta.parse_meta(response))
@@ -405,4 +405,4 @@ def change_protection(
405405
method="POST",
406406
json=data,
407407
)
408-
return BoundAction(self._client.actions, response["action"])
408+
return BoundAction(self._parent.actions, response["action"])

hcloud/load_balancers/client.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ def create(
518518

519519
return CreateLoadBalancerResponse(
520520
load_balancer=BoundLoadBalancer(self, response["load_balancer"]),
521-
action=BoundAction(self._client.actions, response["action"]),
521+
action=BoundAction(self._parent.actions, response["action"]),
522522
)
523523

524524
def update(
@@ -637,7 +637,7 @@ def get_actions_list(
637637
params=params,
638638
)
639639
actions = [
640-
BoundAction(self._client.actions, action_data)
640+
BoundAction(self._parent.actions, action_data)
641641
for action_data in response["actions"]
642642
]
643643
return ActionsPageResult(actions, Meta.parse_meta(response))
@@ -683,7 +683,7 @@ def add_service(
683683
method="POST",
684684
json=data,
685685
)
686-
return BoundAction(self._client.actions, response["action"])
686+
return BoundAction(self._parent.actions, response["action"])
687687

688688
def update_service(
689689
self,
@@ -703,7 +703,7 @@ def update_service(
703703
method="POST",
704704
json=data,
705705
)
706-
return BoundAction(self._client.actions, response["action"])
706+
return BoundAction(self._parent.actions, response["action"])
707707

708708
def delete_service(
709709
self,
@@ -724,7 +724,7 @@ def delete_service(
724724
method="POST",
725725
json=data,
726726
)
727-
return BoundAction(self._client.actions, response["action"])
727+
return BoundAction(self._parent.actions, response["action"])
728728

729729
def add_target(
730730
self,
@@ -745,7 +745,7 @@ def add_target(
745745
method="POST",
746746
json=data,
747747
)
748-
return BoundAction(self._client.actions, response["action"])
748+
return BoundAction(self._parent.actions, response["action"])
749749

750750
def remove_target(
751751
self,
@@ -768,7 +768,7 @@ def remove_target(
768768
method="POST",
769769
json=data,
770770
)
771-
return BoundAction(self._client.actions, response["action"])
771+
return BoundAction(self._parent.actions, response["action"])
772772

773773
def change_algorithm(
774774
self,
@@ -789,7 +789,7 @@ def change_algorithm(
789789
method="POST",
790790
json=data,
791791
)
792-
return BoundAction(self._client.actions, response["action"])
792+
return BoundAction(self._parent.actions, response["action"])
793793

794794
def change_dns_ptr(
795795
self,
@@ -811,7 +811,7 @@ def change_dns_ptr(
811811
method="POST",
812812
json={"ip": ip, "dns_ptr": dns_ptr},
813813
)
814-
return BoundAction(self._client.actions, response["action"])
814+
return BoundAction(self._parent.actions, response["action"])
815815

816816
def change_protection(
817817
self,
@@ -834,7 +834,7 @@ def change_protection(
834834
method="POST",
835835
json=data,
836836
)
837-
return BoundAction(self._client.actions, response["action"])
837+
return BoundAction(self._parent.actions, response["action"])
838838

839839
def attach_to_network(
840840
self,
@@ -859,7 +859,7 @@ def attach_to_network(
859859
method="POST",
860860
json=data,
861861
)
862-
return BoundAction(self._client.actions, response["action"])
862+
return BoundAction(self._parent.actions, response["action"])
863863

864864
def detach_from_network(
865865
self,
@@ -878,7 +878,7 @@ def detach_from_network(
878878
method="POST",
879879
json=data,
880880
)
881-
return BoundAction(self._client.actions, response["action"])
881+
return BoundAction(self._parent.actions, response["action"])
882882

883883
def enable_public_interface(
884884
self,
@@ -895,7 +895,7 @@ def enable_public_interface(
895895
url=f"/load_balancers/{load_balancer.id}/actions/enable_public_interface",
896896
method="POST",
897897
)
898-
return BoundAction(self._client.actions, response["action"])
898+
return BoundAction(self._parent.actions, response["action"])
899899

900900
def disable_public_interface(
901901
self,
@@ -912,7 +912,7 @@ def disable_public_interface(
912912
url=f"/load_balancers/{load_balancer.id}/actions/disable_public_interface",
913913
method="POST",
914914
)
915-
return BoundAction(self._client.actions, response["action"])
915+
return BoundAction(self._parent.actions, response["action"])
916916

917917
def change_type(
918918
self,
@@ -932,4 +932,4 @@ def change_type(
932932
method="POST",
933933
json=data,
934934
)
935-
return BoundAction(self._client.actions, response["action"])
935+
return BoundAction(self._parent.actions, response["action"])

hcloud/networks/client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def get_actions_list(
386386
params=params,
387387
)
388388
actions = [
389-
BoundAction(self._client.actions, action_data)
389+
BoundAction(self._parent.actions, action_data)
390390
for action_data in response["actions"]
391391
]
392392
return ActionsPageResult(actions, Meta.parse_meta(response))
@@ -439,7 +439,7 @@ def add_subnet(
439439
method="POST",
440440
json=data,
441441
)
442-
return BoundAction(self._client.actions, response["action"])
442+
return BoundAction(self._parent.actions, response["action"])
443443

444444
def delete_subnet(
445445
self,
@@ -460,7 +460,7 @@ def delete_subnet(
460460
method="POST",
461461
json=data,
462462
)
463-
return BoundAction(self._client.actions, response["action"])
463+
return BoundAction(self._parent.actions, response["action"])
464464

465465
def add_route(
466466
self,
@@ -484,7 +484,7 @@ def add_route(
484484
method="POST",
485485
json=data,
486486
)
487-
return BoundAction(self._client.actions, response["action"])
487+
return BoundAction(self._parent.actions, response["action"])
488488

489489
def delete_route(
490490
self,
@@ -508,7 +508,7 @@ def delete_route(
508508
method="POST",
509509
json=data,
510510
)
511-
return BoundAction(self._client.actions, response["action"])
511+
return BoundAction(self._parent.actions, response["action"])
512512

513513
def change_ip_range(
514514
self,
@@ -529,7 +529,7 @@ def change_ip_range(
529529
method="POST",
530530
json=data,
531531
)
532-
return BoundAction(self._client.actions, response["action"])
532+
return BoundAction(self._parent.actions, response["action"])
533533

534534
def change_protection(
535535
self,
@@ -552,4 +552,4 @@ def change_protection(
552552
method="POST",
553553
json=data,
554554
)
555-
return BoundAction(self._client.actions, response["action"])
555+
return BoundAction(self._parent.actions, response["action"])

hcloud/placement_groups/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def create(
160160

161161
action = None
162162
if response.get("action") is not None:
163-
action = BoundAction(self._client.actions, response["action"])
163+
action = BoundAction(self._parent.actions, response["action"])
164164

165165
result = CreatePlacementGroupResponse(
166166
placement_group=BoundPlacementGroup(self, response["placement_group"]),

hcloud/primary_ips/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def create(
224224

225225
action = None
226226
if response.get("action") is not None:
227-
action = BoundAction(self._client.actions, response["action"])
227+
action = BoundAction(self._parent.actions, response["action"])
228228

229229
result = CreatePrimaryIPResponse(
230230
primary_ip=BoundPrimaryIP(self, response["primary_ip"]), action=action
@@ -298,7 +298,7 @@ def change_protection(
298298
method="POST",
299299
json=data,
300300
)
301-
return BoundAction(self._client.actions, response["action"])
301+
return BoundAction(self._parent.actions, response["action"])
302302

303303
def assign(
304304
self,
@@ -320,7 +320,7 @@ def assign(
320320
method="POST",
321321
json={"assignee_id": assignee_id, "assignee_type": assignee_type},
322322
)
323-
return BoundAction(self._client.actions, response["action"])
323+
return BoundAction(self._parent.actions, response["action"])
324324

325325
def unassign(self, primary_ip: PrimaryIP | BoundPrimaryIP) -> BoundAction:
326326
"""Unassigns a Primary IP, resulting in it being unreachable. You may assign it to a server again at a later time.
@@ -332,7 +332,7 @@ def unassign(self, primary_ip: PrimaryIP | BoundPrimaryIP) -> BoundAction:
332332
url=f"/primary_ips/{primary_ip.id}/actions/unassign",
333333
method="POST",
334334
)
335-
return BoundAction(self._client.actions, response["action"])
335+
return BoundAction(self._parent.actions, response["action"])
336336

337337
def change_dns_ptr(
338338
self,
@@ -354,4 +354,4 @@ def change_dns_ptr(
354354
method="POST",
355355
json={"ip": ip, "dns_ptr": dns_ptr},
356356
)
357-
return BoundAction(self._client.actions, response["action"])
357+
return BoundAction(self._parent.actions, response["action"])

0 commit comments

Comments
 (0)