1717"""
1818
1919import http
20+ from typing import Any
2021
2122from openstack import exceptions as sdk_exceptions
2223from osc_lib import exceptions
2526# security groups
2627
2728
28- def create_security_group (compute_client , name = None , description = None ):
29+ def create_security_group (
30+ compute_client : Any ,
31+ name : str | None = None ,
32+ description : str | None = None ,
33+ ) -> Any :
2934 """Create a new security group
3035
3136 https://docs.openstack.org/api-ref/compute/#create-security-group
@@ -46,7 +51,9 @@ def create_security_group(compute_client, name=None, description=None):
4651 return response .json ()['security_group' ]
4752
4853
49- def list_security_groups (compute_client , all_projects = None ):
54+ def list_security_groups (
55+ compute_client : Any , all_projects : bool | None = None
56+ ) -> Any :
5057 """Get all security groups
5158
5259 https://docs.openstack.org/api-ref/compute/#list-security-groups
@@ -63,7 +70,7 @@ def list_security_groups(compute_client, all_projects=None):
6370 return response .json ()['security_groups' ]
6471
6572
66- def find_security_group (compute_client , name_or_id ) :
73+ def find_security_group (compute_client : Any , name_or_id : str ) -> Any :
6774 """Find the security group for a given name or ID
6875
6976 https://docs.openstack.org/api-ref/compute/#show-security-group-details
@@ -101,8 +108,11 @@ def find_security_group(compute_client, name_or_id):
101108
102109
103110def update_security_group (
104- compute_client , security_group_id , name = None , description = None
105- ):
111+ compute_client : Any ,
112+ security_group_id : str ,
113+ name : str | None = None ,
114+ description : str | None = None ,
115+ ) -> Any :
106116 """Update an existing security group
107117
108118 https://docs.openstack.org/api-ref/compute/#update-security-group
@@ -127,7 +137,9 @@ def update_security_group(
127137 return response .json ()['security_group' ]
128138
129139
130- def delete_security_group (compute_client , security_group_id = None ):
140+ def delete_security_group (
141+ compute_client : Any , security_group_id : str | None = None
142+ ) -> None :
131143 """Delete a security group
132144
133145 https://docs.openstack.org/api-ref/compute/#delete-security-group
@@ -146,14 +158,14 @@ def delete_security_group(compute_client, security_group_id=None):
146158
147159
148160def create_security_group_rule (
149- compute_client ,
150- security_group_id = None ,
151- ip_protocol = None ,
152- from_port = None ,
153- to_port = None ,
154- remote_ip = None ,
155- remote_group = None ,
156- ):
161+ compute_client : Any ,
162+ security_group_id : str | None = None ,
163+ ip_protocol : str | None = None ,
164+ from_port : int | None = None ,
165+ to_port : int | None = None ,
166+ remote_ip : str | None = None ,
167+ remote_group : str | None = None ,
168+ ) -> Any :
157169 """Create a new security group rule
158170
159171 https://docs.openstack.org/api-ref/compute/#create-security-group-rule
@@ -182,7 +194,9 @@ def create_security_group_rule(
182194 return response .json ()['security_group_rule' ]
183195
184196
185- def delete_security_group_rule (compute_client , security_group_rule_id = None ):
197+ def delete_security_group_rule (
198+ compute_client : Any , security_group_rule_id : str | None = None
199+ ) -> None :
186200 """Delete a security group rule
187201
188202 https://docs.openstack.org/api-ref/compute/#delete-security-group-rule
@@ -201,7 +215,12 @@ def delete_security_group_rule(compute_client, security_group_rule_id=None):
201215# networks
202216
203217
204- def create_network (compute_client , name , subnet , share_subnet = None ):
218+ def create_network (
219+ compute_client : Any ,
220+ name : str ,
221+ subnet : str ,
222+ share_subnet : bool | None = None ,
223+ ) -> Any :
205224 """Create a new network
206225
207226 https://docs.openstack.org/api-ref/compute/#create-network
@@ -212,7 +231,7 @@ def create_network(compute_client, name, subnet, share_subnet=None):
212231 :param bool share_subnet: Shared subnet between projects
213232 :returns: A network object
214233 """
215- data = {
234+ data : dict [ str , Any ] = {
216235 'label' : name ,
217236 'cidr' : subnet ,
218237 }
@@ -226,7 +245,7 @@ def create_network(compute_client, name, subnet, share_subnet=None):
226245 return response .json ()['network' ]
227246
228247
229- def list_networks (compute_client ) :
248+ def list_networks (compute_client : Any ) -> Any :
230249 """Get all networks
231250
232251 https://docs.openstack.org/api-ref/compute/#list-networks
@@ -239,7 +258,7 @@ def list_networks(compute_client):
239258 return response .json ()['networks' ]
240259
241260
242- def find_network (compute_client , name_or_id ) :
261+ def find_network (compute_client : Any , name_or_id : str ) -> Any :
243262 """Find the network for a given name or ID
244263
245264 https://docs.openstack.org/api-ref/compute/#show-network-details
@@ -276,7 +295,7 @@ def find_network(compute_client, name_or_id):
276295 return found
277296
278297
279- def delete_network (compute_client , network_id ) :
298+ def delete_network (compute_client : Any , network_id : str ) -> None :
280299 """Delete a network
281300
282301 https://docs.openstack.org/api-ref/compute/#delete-network
@@ -294,7 +313,7 @@ def delete_network(compute_client, network_id):
294313# floating ips
295314
296315
297- def create_floating_ip (compute_client , network ) :
316+ def create_floating_ip (compute_client : Any , network : str ) -> Any :
298317 """Create a new floating ip
299318
300319 https://docs.openstack.org/api-ref/compute/#create-allocate-floating-ip-address
@@ -309,7 +328,7 @@ def create_floating_ip(compute_client, network):
309328 return response .json ()['floating_ip' ]
310329
311330
312- def list_floating_ips (compute_client ) :
331+ def list_floating_ips (compute_client : Any ) -> Any :
313332 """Get all floating IPs
314333
315334 https://docs.openstack.org/api-ref/compute/#list-floating-ip-addresses
@@ -321,7 +340,7 @@ def list_floating_ips(compute_client):
321340 return response .json ()['floating_ips' ]
322341
323342
324- def get_floating_ip (compute_client , floating_ip_id ) :
343+ def get_floating_ip (compute_client : Any , floating_ip_id : str ) -> Any :
325344 """Get a floating IP
326345
327346 https://docs.openstack.org/api-ref/compute/#show-floating-ip-address-details
@@ -336,7 +355,7 @@ def get_floating_ip(compute_client, floating_ip_id):
336355 return response .json ()['floating_ip' ]
337356
338357
339- def delete_floating_ip (compute_client , floating_ip_id ) :
358+ def delete_floating_ip (compute_client : Any , floating_ip_id : str ) -> None :
340359 """Delete a floating IP
341360
342361 https://docs.openstack.org/api-ref/compute/#delete-deallocate-floating-ip-address
@@ -353,7 +372,7 @@ def delete_floating_ip(compute_client, floating_ip_id):
353372# floating ip pools
354373
355374
356- def list_floating_ip_pools (compute_client ) :
375+ def list_floating_ip_pools (compute_client : Any ) -> Any :
357376 """Get all floating IP pools
358377
359378 https://docs.openstack.org/api-ref/compute/#list-floating-ip-pools
0 commit comments