Skip to content

Commit 63fe718

Browse files
authored
refactor: use kwargs when proxying bound model client (#564)
Related to #546
1 parent 61ec52d commit 63fe718

File tree

11 files changed

+142
-58
lines changed

11 files changed

+142
-58
lines changed

hcloud/certificates/client.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ def get_actions_list(
5353
Specifies how many results are returned by page
5454
:return: (List[:class:`BoundAction <hcloud.actions.client.BoundAction>`], :class:`Meta <hcloud.core.domain.Meta>`)
5555
"""
56-
return self._client.get_actions_list(self, status, sort, page, per_page)
56+
return self._client.get_actions_list(
57+
self,
58+
status=status,
59+
sort=sort,
60+
page=page,
61+
per_page=per_page,
62+
)
5763

5864
def get_actions(
5965
self,
@@ -68,7 +74,11 @@ def get_actions(
6874
Specify how the results are sorted. Choices: `id` `id:asc` `id:desc` `command` `command:asc` `command:desc` `status` `status:asc` `status:desc` `progress` `progress:asc` `progress:desc` `started` `started:asc` `started:desc` `finished` `finished:asc` `finished:desc`
6975
:return: List[:class:`BoundAction <hcloud.actions.client.BoundAction>`]
7076
"""
71-
return self._client.get_actions(self, status, sort)
77+
return self._client.get_actions(
78+
self,
79+
status=status,
80+
sort=sort,
81+
)
7282

7383
def update(
7484
self,
@@ -83,7 +93,11 @@ def update(
8393
User-defined labels (key-value pairs)
8494
:return: :class:`BoundCertificate <hcloud.certificates.client.BoundCertificate>`
8595
"""
86-
return self._client.update(self, name, labels)
96+
return self._client.update(
97+
self,
98+
name=name,
99+
labels=labels,
100+
)
87101

88102
def delete(self) -> bool:
89103
"""Deletes a certificate.

hcloud/firewalls/client.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,13 @@ def get_actions_list(
109109
Specifies how many results are returned by page
110110
:return: (List[:class:`BoundAction <hcloud.actions.client.BoundAction>`], :class:`Meta <hcloud.core.domain.Meta>`)
111111
"""
112-
return self._client.get_actions_list(self, status, sort, page, per_page)
112+
return self._client.get_actions_list(
113+
self,
114+
status=status,
115+
sort=sort,
116+
page=page,
117+
per_page=per_page,
118+
)
113119

114120
def get_actions(
115121
self,
@@ -125,7 +131,11 @@ def get_actions(
125131
126132
:return: List[:class:`BoundAction <hcloud.actions.client.BoundAction>`]
127133
"""
128-
return self._client.get_actions(self, status, sort)
134+
return self._client.get_actions(
135+
self,
136+
status=status,
137+
sort=sort,
138+
)
129139

130140
def update(
131141
self,
@@ -140,7 +150,7 @@ def update(
140150
New Name to set
141151
:return: :class:`BoundFirewall <hcloud.firewalls.client.BoundFirewall>`
142152
"""
143-
return self._client.update(self, labels, name)
153+
return self._client.update(self, name=name, labels=labels)
144154

145155
def delete(self) -> bool:
146156
"""Deletes a Firewall.
@@ -155,7 +165,7 @@ def set_rules(self, rules: list[FirewallRule]) -> list[BoundAction]:
155165
:return: List[:class:`BoundAction <hcloud.actions.client.BoundAction>`]
156166
"""
157167

158-
return self._client.set_rules(self, rules)
168+
return self._client.set_rules(self, rules=rules)
159169

160170
def apply_to_resources(
161171
self,
@@ -165,7 +175,7 @@ def apply_to_resources(
165175
:param resources: List[:class:`FirewallResource <hcloud.firewalls.domain.FirewallResource>`]
166176
:return: List[:class:`BoundAction <hcloud.actions.client.BoundAction>`]
167177
"""
168-
return self._client.apply_to_resources(self, resources)
178+
return self._client.apply_to_resources(self, resources=resources)
169179

170180
def remove_from_resources(
171181
self,
@@ -175,7 +185,7 @@ def remove_from_resources(
175185
:param resources: List[:class:`FirewallResource <hcloud.firewalls.domain.FirewallResource>`]
176186
:return: List[:class:`BoundAction <hcloud.actions.client.BoundAction>`]
177187
"""
178-
return self._client.remove_from_resources(self, resources)
188+
return self._client.remove_from_resources(self, resources=resources)
179189

180190

181191
class FirewallsPageResult(NamedTuple):

hcloud/floating_ips/client.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ def get_actions_list(
5555
Specifies how many results are returned by page
5656
:return: (List[:class:`BoundAction <hcloud.actions.client.BoundAction>`], :class:`Meta <hcloud.core.domain.Meta>`)
5757
"""
58-
return self._client.get_actions_list(self, status, sort, page, per_page)
58+
return self._client.get_actions_list(
59+
self,
60+
status=status,
61+
sort=sort,
62+
page=page,
63+
per_page=per_page,
64+
)
5965

6066
def get_actions(
6167
self,
@@ -70,7 +76,7 @@ def get_actions(
7076
Specify how the results are sorted. Choices: `id` `id:asc` `id:desc` `command` `command:asc` `command:desc` `status` `status:asc` `status:desc` `progress` `progress:asc` `progress:desc` `started` `started:asc` `started:desc` `finished` `finished:asc` `finished:desc`
7177
:return: List[:class:`BoundAction <hcloud.actions.client.BoundAction>`]
7278
"""
73-
return self._client.get_actions(self, status, sort)
79+
return self._client.get_actions(self, status=status, sort=sort)
7480

7581
def update(
7682
self,
@@ -88,7 +94,9 @@ def update(
8894
New Name to set
8995
:return: :class:`BoundFloatingIP <hcloud.floating_ips.client.BoundFloatingIP>`
9096
"""
91-
return self._client.update(self, description, labels, name)
97+
return self._client.update(
98+
self, description=description, labels=labels, name=name
99+
)
92100

93101
def delete(self) -> bool:
94102
"""Deletes a Floating IP. If it is currently assigned to a server it will automatically get unassigned.
@@ -104,7 +112,7 @@ def change_protection(self, delete: bool | None = None) -> BoundAction:
104112
If true, prevents the Floating IP from being deleted
105113
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
106114
"""
107-
return self._client.change_protection(self, delete)
115+
return self._client.change_protection(self, delete=delete)
108116

109117
def assign(self, server: Server | BoundServer) -> BoundAction:
110118
"""Assigns a Floating IP to a server.
@@ -113,7 +121,7 @@ def assign(self, server: Server | BoundServer) -> BoundAction:
113121
Server the Floating IP shall be assigned to
114122
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
115123
"""
116-
return self._client.assign(self, server)
124+
return self._client.assign(self, server=server)
117125

118126
def unassign(self) -> BoundAction:
119127
"""Unassigns a Floating IP, resulting in it being unreachable. You may assign it to a server again at a later time.
@@ -131,7 +139,7 @@ def change_dns_ptr(self, ip: str, dns_ptr: str) -> BoundAction:
131139
Hostname to set as a reverse DNS PTR entry, will reset to original default value if `None`
132140
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
133141
"""
134-
return self._client.change_dns_ptr(self, ip, dns_ptr)
142+
return self._client.change_dns_ptr(self, ip=ip, dns_ptr=dns_ptr)
135143

136144

137145
class FloatingIPsPageResult(NamedTuple):

hcloud/images/client.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ def get_actions_list(
5353
:return: (List[:class:`BoundAction <hcloud.actions.client.BoundAction>`], :class:`Meta <hcloud.core.domain.Meta>`)
5454
"""
5555
return self._client.get_actions_list(
56-
self, sort=sort, page=page, per_page=per_page, status=status
56+
self,
57+
sort=sort,
58+
page=page,
59+
per_page=per_page,
60+
status=status,
5761
)
5862

5963
def get_actions(
@@ -69,7 +73,11 @@ def get_actions(
6973
Specify how the results are sorted. Choices: `id` `id:asc` `id:desc` `command` `command:asc` `command:desc` `status` `status:asc` `status:desc` `progress` `progress:asc` `progress:desc` `started` `started:asc` `started:desc` `finished` `finished:asc` `finished:desc`
7074
:return: List[:class:`BoundAction <hcloud.actions.client.BoundAction>`]
7175
"""
72-
return self._client.get_actions(self, status=status, sort=sort)
76+
return self._client.get_actions(
77+
self,
78+
status=status,
79+
sort=sort,
80+
)
7381

7482
def update(
7583
self,
@@ -88,7 +96,9 @@ def update(
8896
User-defined labels (key-value pairs)
8997
:return: :class:`BoundImage <hcloud.images.client.BoundImage>`
9098
"""
91-
return self._client.update(self, description, type, labels)
99+
return self._client.update(
100+
self, description=description, type=type, labels=labels
101+
)
92102

93103
def delete(self) -> bool:
94104
"""Deletes an Image. Only images of type snapshot and backup can be deleted.
@@ -104,7 +114,7 @@ def change_protection(self, delete: bool | None = None) -> BoundAction:
104114
If true, prevents the snapshot from being deleted
105115
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
106116
"""
107-
return self._client.change_protection(self, delete)
117+
return self._client.change_protection(self, delete=delete)
108118

109119

110120
class ImagesPageResult(NamedTuple):

hcloud/load_balancers/client.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def update(
174174
User-defined labels (key-value pairs)
175175
:return: :class:`BoundLoadBalancer <hcloud.load_balancers.client.BoundLoadBalancer>`
176176
"""
177-
return self._client.update(self, name, labels)
177+
return self._client.update(self, name=name, labels=labels)
178178

179179
def delete(self) -> bool:
180180
"""Deletes a Load Balancer.
@@ -224,7 +224,13 @@ def get_actions_list(
224224
Specifies how many results are returned by page
225225
:return: (List[:class:`BoundAction <hcloud.actions.client.BoundAction>`], :class:`Meta <hcloud.core.domain.Meta>`)
226226
"""
227-
return self._client.get_actions_list(self, status, sort, page, per_page)
227+
return self._client.get_actions_list(
228+
self,
229+
status=status,
230+
sort=sort,
231+
page=page,
232+
per_page=per_page,
233+
)
228234

229235
def get_actions(
230236
self,
@@ -239,7 +245,7 @@ def get_actions(
239245
Specify how the results are sorted. Choices: `id` `id:asc` `id:desc` `command` `command:asc` `command:desc` `status` `status:asc` `status:desc` `progress` `progress:asc` `progress:desc` `started` `started:asc` `started:desc` `finished` `finished:asc` `finished:desc`
240246
:return: List[:class:`BoundAction <hcloud.actions.client.BoundAction>`]
241247
"""
242-
return self._client.get_actions(self, status, sort)
248+
return self._client.get_actions(self, status=status, sort=sort)
243249

244250
def add_service(self, service: LoadBalancerService) -> BoundAction:
245251
"""Adds a service to a Load Balancer.
@@ -266,7 +272,7 @@ def delete_service(self, service: LoadBalancerService) -> BoundAction:
266272
The LoadBalancerService you want to delete from the Load Balancer
267273
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
268274
"""
269-
return self._client.delete_service(self, service)
275+
return self._client.delete_service(self, service=service)
270276

271277
def add_target(self, target: LoadBalancerTarget) -> BoundAction:
272278
"""Adds a target to a Load Balancer.
@@ -275,7 +281,7 @@ def add_target(self, target: LoadBalancerTarget) -> BoundAction:
275281
The LoadBalancerTarget you want to add to the Load Balancer
276282
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
277283
"""
278-
return self._client.add_target(self, target)
284+
return self._client.add_target(self, target=target)
279285

280286
def remove_target(self, target: LoadBalancerTarget) -> BoundAction:
281287
"""Removes a target from a Load Balancer.
@@ -284,7 +290,7 @@ def remove_target(self, target: LoadBalancerTarget) -> BoundAction:
284290
The LoadBalancerTarget you want to remove from the Load Balancer
285291
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
286292
"""
287-
return self._client.remove_target(self, target)
293+
return self._client.remove_target(self, target=target)
288294

289295
def change_algorithm(self, algorithm: LoadBalancerAlgorithm) -> BoundAction:
290296
"""Changes the algorithm used by the Load Balancer
@@ -293,7 +299,7 @@ def change_algorithm(self, algorithm: LoadBalancerAlgorithm) -> BoundAction:
293299
The LoadBalancerAlgorithm you want to use
294300
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
295301
"""
296-
return self._client.change_algorithm(self, algorithm)
302+
return self._client.change_algorithm(self, algorithm=algorithm)
297303

298304
def change_dns_ptr(self, ip: str, dns_ptr: str) -> BoundAction:
299305
"""Changes the hostname that will appear when getting the hostname belonging to the public IPs (IPv4 and IPv6) of this Load Balancer.
@@ -304,7 +310,7 @@ def change_dns_ptr(self, ip: str, dns_ptr: str) -> BoundAction:
304310
Hostname to set as a reverse DNS PTR entry, will reset to original default value if `None`
305311
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
306312
"""
307-
return self._client.change_dns_ptr(self, ip, dns_ptr)
313+
return self._client.change_dns_ptr(self, ip=ip, dns_ptr=dns_ptr)
308314

309315
def change_protection(self, delete: bool) -> BoundAction:
310316
"""Changes the protection configuration of a Load Balancer.
@@ -313,7 +319,7 @@ def change_protection(self, delete: bool) -> BoundAction:
313319
If True, prevents the Load Balancer from being deleted
314320
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
315321
"""
316-
return self._client.change_protection(self, delete)
322+
return self._client.change_protection(self, delete=delete)
317323

318324
def attach_to_network(
319325
self,
@@ -330,15 +336,20 @@ def attach_to_network(
330336
IP range in CIDR block notation of the subnet to attach to.
331337
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
332338
"""
333-
return self._client.attach_to_network(self, network, ip, ip_range)
339+
return self._client.attach_to_network(
340+
self,
341+
network=network,
342+
ip=ip,
343+
ip_range=ip_range,
344+
)
334345

335346
def detach_from_network(self, network: Network | BoundNetwork) -> BoundAction:
336347
"""Detaches a Load Balancer from a Network.
337348
338349
:param network: :class:`BoundNetwork <hcloud.networks.client.BoundNetwork>` or :class:`Network <hcloud.networks.domain.Network>`
339350
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
340351
"""
341-
return self._client.detach_from_network(self, network)
352+
return self._client.detach_from_network(self, network=network)
342353

343354
def enable_public_interface(self) -> BoundAction:
344355
"""Enables the public interface of a Load Balancer.
@@ -364,7 +375,7 @@ def change_type(
364375
Load Balancer type the Load Balancer should migrate to
365376
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
366377
"""
367-
return self._client.change_type(self, load_balancer_type)
378+
return self._client.change_type(self, load_balancer_type=load_balancer_type)
368379

369380

370381
class LoadBalancersPageResult(NamedTuple):

hcloud/networks/client.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@ def get_actions_list(
8989
Specifies how many results are returned by page
9090
:return: (List[:class:`BoundAction <hcloud.actions.client.BoundAction>`], :class:`Meta <hcloud.core.domain.Meta>`)
9191
"""
92-
return self._client.get_actions_list(self, status, sort, page, per_page)
92+
return self._client.get_actions_list(
93+
self,
94+
status=status,
95+
sort=sort,
96+
page=page,
97+
per_page=per_page,
98+
)
9399

94100
def get_actions(
95101
self,
@@ -104,7 +110,7 @@ def get_actions(
104110
Specify how the results are sorted. Choices: `id` `id:asc` `id:desc` `command` `command:asc` `command:desc` `status` `status:asc` `status:desc` `progress` `progress:asc` `progress:desc` `started` `started:asc` `started:desc` `finished` `finished:asc` `finished:desc`
105111
:return: List[:class:`BoundAction <hcloud.actions.client.BoundAction>`]
106112
"""
107-
return self._client.get_actions(self, status, sort)
113+
return self._client.get_actions(self, status=status, sort=sort)
108114

109115
def add_subnet(self, subnet: NetworkSubnet) -> BoundAction:
110116
"""Adds a subnet entry to a network.

hcloud/placement_groups/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def update(
2525
New Name to set
2626
:return: :class:`BoundPlacementGroup <hcloud.placement_groups.client.BoundPlacementGroup>`
2727
"""
28-
return self._client.update(self, labels, name)
28+
return self._client.update(self, labels=labels, name=name)
2929

3030
def delete(self) -> bool:
3131
"""Deletes a Placement Group

0 commit comments

Comments
 (0)