python-openstackclient 9.0.0__py3-none-any.whl → 10.0.0__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.
Files changed (284) hide show
  1. openstackclient/__init__.py +2 -6
  2. openstackclient/api/api.py +41 -23
  3. openstackclient/api/compute_v2.py +44 -25
  4. openstackclient/api/object_store_v1.py +75 -97
  5. openstackclient/api/volume_v2.py +2 -1
  6. openstackclient/api/volume_v3.py +2 -1
  7. openstackclient/common/availability_zone.py +58 -42
  8. openstackclient/common/clientmanager.py +56 -29
  9. openstackclient/common/configuration.py +10 -3
  10. openstackclient/common/envvars.py +2 -2
  11. openstackclient/common/extension.py +14 -5
  12. openstackclient/common/limits.py +10 -5
  13. openstackclient/common/module.py +14 -6
  14. openstackclient/common/pagination.py +8 -2
  15. openstackclient/common/progressbar.py +7 -6
  16. openstackclient/common/project_cleanup.py +13 -7
  17. openstackclient/common/quota.py +97 -99
  18. openstackclient/common/versions.py +8 -2
  19. openstackclient/compute/client.py +7 -3
  20. openstackclient/compute/v2/agent.py +17 -10
  21. openstackclient/compute/v2/aggregate.py +36 -22
  22. openstackclient/compute/v2/console.py +14 -8
  23. openstackclient/compute/v2/console_connection.py +11 -3
  24. openstackclient/compute/v2/flavor.py +39 -21
  25. openstackclient/compute/v2/host.py +14 -6
  26. openstackclient/compute/v2/hypervisor.py +14 -5
  27. openstackclient/compute/v2/hypervisor_stats.py +10 -2
  28. openstackclient/compute/v2/keypair.py +29 -14
  29. openstackclient/compute/v2/server.py +249 -169
  30. openstackclient/compute/v2/server_backup.py +10 -4
  31. openstackclient/compute/v2/server_event.py +21 -12
  32. openstackclient/compute/v2/server_group.py +21 -11
  33. openstackclient/compute/v2/server_image.py +19 -10
  34. openstackclient/compute/v2/server_migration.py +24 -10
  35. openstackclient/compute/v2/server_share.py +274 -0
  36. openstackclient/compute/v2/server_volume.py +10 -4
  37. openstackclient/compute/v2/service.py +14 -7
  38. openstackclient/compute/v2/usage.py +26 -21
  39. openstackclient/identity/client.py +8 -3
  40. openstackclient/identity/common.py +78 -47
  41. openstackclient/identity/v2_0/catalog.py +14 -7
  42. openstackclient/identity/v2_0/ec2creds.py +21 -10
  43. openstackclient/identity/v2_0/endpoint.py +23 -11
  44. openstackclient/identity/v2_0/project.py +25 -14
  45. openstackclient/identity/v2_0/role.py +28 -14
  46. openstackclient/identity/v2_0/role_assignment.py +9 -3
  47. openstackclient/identity/v2_0/service.py +23 -11
  48. openstackclient/identity/v2_0/token.py +12 -5
  49. openstackclient/identity/v2_0/user.py +26 -15
  50. openstackclient/identity/v3/access_rule.py +26 -12
  51. openstackclient/identity/v3/application_credential.py +59 -24
  52. openstackclient/identity/v3/catalog.py +14 -7
  53. openstackclient/identity/v3/consumer.py +22 -11
  54. openstackclient/identity/v3/credential.py +36 -16
  55. openstackclient/identity/v3/domain.py +37 -18
  56. openstackclient/identity/v3/ec2creds.py +25 -12
  57. openstackclient/identity/v3/endpoint.py +42 -20
  58. openstackclient/identity/v3/endpoint_group.py +28 -17
  59. openstackclient/identity/v3/federation_protocol.py +38 -16
  60. openstackclient/identity/v3/group.py +55 -32
  61. openstackclient/identity/v3/identity_provider.py +92 -57
  62. openstackclient/identity/v3/implied_role.py +21 -9
  63. openstackclient/identity/v3/limit.py +38 -16
  64. openstackclient/identity/v3/mapping.py +26 -13
  65. openstackclient/identity/v3/policy.py +23 -12
  66. openstackclient/identity/v3/project.py +43 -23
  67. openstackclient/identity/v3/region.py +36 -16
  68. openstackclient/identity/v3/registered_limit.py +40 -16
  69. openstackclient/identity/v3/role.py +61 -31
  70. openstackclient/identity/v3/role_assignment.py +23 -6
  71. openstackclient/identity/v3/service.py +36 -16
  72. openstackclient/identity/v3/service_provider.py +37 -15
  73. openstackclient/identity/v3/tag.py +23 -6
  74. openstackclient/identity/v3/token.py +30 -14
  75. openstackclient/identity/v3/trust.py +32 -14
  76. openstackclient/identity/v3/unscoped_saml.py +10 -2
  77. openstackclient/identity/v3/user.py +49 -26
  78. openstackclient/image/client.py +7 -3
  79. openstackclient/image/v1/image.py +33 -26
  80. openstackclient/image/v2/cache.py +14 -9
  81. openstackclient/image/v2/image.py +74 -48
  82. openstackclient/image/v2/info.py +7 -1
  83. openstackclient/image/v2/metadef_namespaces.py +109 -13
  84. openstackclient/image/v2/metadef_objects.py +28 -15
  85. openstackclient/image/v2/metadef_properties.py +24 -13
  86. openstackclient/image/v2/metadef_resource_type_association.py +14 -7
  87. openstackclient/image/v2/metadef_resource_types.py +7 -1
  88. openstackclient/image/v2/task.py +15 -6
  89. openstackclient/locale/tr_TR/LC_MESSAGES/openstackclient.po +7 -192
  90. openstackclient/network/client.py +7 -2
  91. openstackclient/network/common.py +16 -241
  92. openstackclient/network/utils.py +36 -22
  93. openstackclient/network/v2/address_group.py +27 -16
  94. openstackclient/network/v2/address_scope.py +24 -13
  95. openstackclient/network/v2/bgpvpn/bgpvpn.py +463 -0
  96. openstackclient/network/v2/bgpvpn/constants.py +30 -0
  97. openstackclient/network/v2/bgpvpn/network_association.py +214 -0
  98. openstackclient/network/v2/bgpvpn/port_association.py +490 -0
  99. openstackclient/network/v2/bgpvpn/router_association.py +288 -0
  100. openstackclient/network/v2/default_security_group_rule.py +19 -10
  101. openstackclient/network/v2/floating_ip.py +110 -159
  102. openstackclient/network/v2/floating_ip_port_forwarding.py +30 -18
  103. openstackclient/network/v2/fwaas/__init__.py +0 -0
  104. openstackclient/network/v2/fwaas/group.py +466 -0
  105. openstackclient/network/v2/fwaas/policy.py +518 -0
  106. openstackclient/network/v2/fwaas/rule.py +574 -0
  107. openstackclient/network/v2/ip_availability.py +13 -5
  108. openstackclient/network/v2/l3_conntrack_helper.py +22 -13
  109. openstackclient/network/v2/local_ip.py +24 -13
  110. openstackclient/network/v2/local_ip_association.py +14 -7
  111. openstackclient/network/v2/ndp_proxy.py +20 -11
  112. openstackclient/network/v2/network.py +129 -196
  113. openstackclient/network/v2/network_agent.py +46 -25
  114. openstackclient/network/v2/network_auto_allocated_topology.py +22 -11
  115. openstackclient/network/v2/network_flavor.py +27 -16
  116. openstackclient/network/v2/network_flavor_profile.py +23 -12
  117. openstackclient/network/v2/network_meter.py +21 -10
  118. openstackclient/network/v2/network_meter_rule.py +21 -11
  119. openstackclient/network/v2/network_qos_policy.py +25 -15
  120. openstackclient/network/v2/network_qos_rule.py +32 -17
  121. openstackclient/network/v2/network_qos_rule_type.py +13 -5
  122. openstackclient/network/v2/network_rbac.py +23 -12
  123. openstackclient/network/v2/network_segment.py +20 -11
  124. openstackclient/network/v2/network_segment_range.py +56 -29
  125. openstackclient/network/v2/network_service_provider.py +7 -1
  126. openstackclient/network/v2/network_trunk.py +38 -22
  127. openstackclient/network/v2/port.py +54 -29
  128. openstackclient/network/v2/router.py +75 -52
  129. openstackclient/network/v2/security_group.py +87 -157
  130. openstackclient/network/v2/security_group_rule.py +100 -280
  131. openstackclient/network/v2/subnet.py +49 -28
  132. openstackclient/network/v2/subnet_pool.py +30 -17
  133. openstackclient/network/v2/taas/tap_flow.py +22 -11
  134. openstackclient/network/v2/taas/tap_mirror.py +22 -11
  135. openstackclient/network/v2/taas/tap_service.py +23 -12
  136. openstackclient/object/client.py +7 -2
  137. openstackclient/object/v1/account.py +13 -6
  138. openstackclient/object/v1/container.py +25 -15
  139. openstackclient/object/v1/object.py +25 -15
  140. openstackclient/py.typed +0 -0
  141. openstackclient/shell.py +46 -10
  142. openstackclient/tests/functional/base.py +55 -20
  143. openstackclient/tests/functional/common/test_extension.py +4 -0
  144. openstackclient/tests/functional/common/test_quota.py +3 -1
  145. openstackclient/tests/functional/compute/v2/common.py +14 -13
  146. openstackclient/tests/functional/compute/v2/test_flavor.py +3 -1
  147. openstackclient/tests/functional/compute/v2/test_server.py +3 -0
  148. openstackclient/tests/functional/identity/v2/common.py +10 -6
  149. openstackclient/tests/functional/identity/v2/test_role.py +4 -4
  150. openstackclient/tests/functional/identity/v3/common.py +25 -19
  151. openstackclient/tests/functional/identity/v3/test_group.py +20 -20
  152. openstackclient/tests/functional/identity/v3/test_idp.py +3 -1
  153. openstackclient/tests/functional/identity/v3/test_project.py +10 -10
  154. openstackclient/tests/functional/identity/v3/test_role.py +18 -18
  155. openstackclient/tests/functional/identity/v3/test_role_assignment.py +12 -12
  156. openstackclient/tests/functional/identity/v3/test_user.py +8 -8
  157. openstackclient/tests/functional/image/base.py +1 -6
  158. openstackclient/tests/functional/network/v2/common.py +5 -2
  159. openstackclient/tests/functional/network/v2/test_floating_ip.py +10 -4
  160. openstackclient/tests/functional/network/v2/test_ip_availability.py +4 -0
  161. openstackclient/tests/functional/network/v2/test_network_meter_rule.py +3 -2
  162. openstackclient/tests/functional/network/v2/test_network_segment.py +5 -0
  163. openstackclient/tests/functional/network/v2/test_subnet.py +13 -9
  164. openstackclient/tests/functional/object/v1/common.py +4 -0
  165. openstackclient/tests/functional/volume/v2/common.py +4 -0
  166. openstackclient/tests/functional/volume/v2/test_volume_snapshot.py +27 -11
  167. openstackclient/tests/functional/volume/v2/test_volume_type.py +2 -2
  168. openstackclient/tests/functional/volume/v3/common.py +4 -0
  169. openstackclient/tests/functional/volume/v3/test_volume_snapshot.py +11 -7
  170. openstackclient/tests/functional/volume/v3/test_volume_type.py +2 -2
  171. openstackclient/tests/unit/common/test_availability_zone.py +35 -49
  172. openstackclient/tests/unit/common/test_extension.py +2 -2
  173. openstackclient/tests/unit/common/test_module.py +12 -7
  174. openstackclient/tests/unit/common/test_project_cleanup.py +3 -1
  175. openstackclient/tests/unit/common/test_quota.py +6 -26
  176. openstackclient/tests/unit/compute/v2/fakes.py +25 -0
  177. openstackclient/tests/unit/compute/v2/test_flavor.py +28 -2
  178. openstackclient/tests/unit/compute/v2/test_keypair.py +6 -6
  179. openstackclient/tests/unit/compute/v2/test_server.py +11 -96
  180. openstackclient/tests/unit/compute/v2/test_server_share.py +287 -0
  181. openstackclient/tests/unit/identity/v3/fakes.py +3 -0
  182. openstackclient/tests/unit/identity/v3/test_group.py +4 -14
  183. openstackclient/tests/unit/identity/v3/test_identity_provider.py +303 -299
  184. openstackclient/tests/unit/identity/v3/test_user.py +4 -4
  185. openstackclient/tests/unit/image/v2/test_image.py +11 -11
  186. openstackclient/tests/unit/image/v2/test_metadef_namespaces.py +105 -6
  187. openstackclient/tests/unit/network/test_common.py +0 -155
  188. openstackclient/tests/unit/network/v2/bgpvpn/__init__.py +0 -0
  189. openstackclient/tests/unit/network/v2/bgpvpn/fakes.py +179 -0
  190. openstackclient/tests/unit/network/v2/bgpvpn/test_bgpvpn.py +584 -0
  191. openstackclient/tests/unit/network/v2/bgpvpn/test_network_association.py +285 -0
  192. openstackclient/tests/unit/network/v2/bgpvpn/test_port_association.py +384 -0
  193. openstackclient/tests/unit/network/v2/bgpvpn/test_router_association.py +297 -0
  194. openstackclient/tests/unit/network/v2/fwaas/__init__.py +0 -0
  195. openstackclient/tests/unit/network/v2/fwaas/test_group.py +897 -0
  196. openstackclient/tests/unit/network/v2/fwaas/test_policy.py +869 -0
  197. openstackclient/tests/unit/network/v2/fwaas/test_rule.py +980 -0
  198. openstackclient/tests/unit/network/v2/taas/{test_osc_tap_flow.py → test_tap_flow.py} +18 -25
  199. openstackclient/tests/unit/network/v2/taas/{test_osc_tap_mirror.py → test_tap_mirror.py} +19 -29
  200. openstackclient/tests/unit/network/v2/taas/{test_osc_tap_service.py → test_tap_service.py} +19 -29
  201. openstackclient/tests/unit/network/v2/test_address_group.py +2 -2
  202. openstackclient/tests/unit/network/v2/{test_floating_ip_network.py → test_floating_ip.py} +3 -2
  203. openstackclient/tests/unit/network/v2/test_floating_ip_port_forwarding.py +13 -13
  204. openstackclient/tests/unit/network/v2/test_network_agent.py +8 -4
  205. openstackclient/tests/unit/network/v2/test_network_auto_allocated_topology.py +3 -3
  206. openstackclient/tests/unit/network/v2/test_network_flavor.py +2 -2
  207. openstackclient/tests/unit/network/v2/test_network_qos_policy.py +1 -1
  208. openstackclient/tests/unit/network/v2/test_network_qos_rule.py +2 -2
  209. openstackclient/tests/unit/network/v2/test_network_rbac.py +1 -1
  210. openstackclient/tests/unit/network/v2/test_network_segment.py +1 -1
  211. openstackclient/tests/unit/network/v2/test_network_segment_range.py +7 -10
  212. openstackclient/tests/unit/network/v2/test_network_trunk.py +1 -1
  213. openstackclient/tests/unit/network/v2/test_router.py +8 -9
  214. openstackclient/tests/unit/network/v2/{test_security_group_network.py → test_security_group.py} +1 -20
  215. openstackclient/tests/unit/network/v2/{test_security_group_rule_network.py → test_security_group_rule.py} +7 -41
  216. openstackclient/tests/unit/network/v2/test_subnet.py +2 -1
  217. openstackclient/tests/unit/network/v2/test_subnet_pool.py +2 -1
  218. openstackclient/tests/unit/object/v1/fakes.py +8 -7
  219. openstackclient/tests/unit/object/v1/test_container.py +65 -101
  220. openstackclient/tests/unit/object/v1/test_container_all.py +8 -1
  221. openstackclient/tests/unit/object/v1/test_object.py +44 -84
  222. openstackclient/tests/unit/object/v1/test_object_all.py +8 -1
  223. openstackclient/tests/unit/test_hacking.py +108 -0
  224. openstackclient/tests/unit/volume/v2/fakes.py +1 -0
  225. openstackclient/tests/unit/volume/v2/test_volume_backup.py +1 -5
  226. openstackclient/tests/unit/volume/v2/test_volume_snapshot.py +2 -1
  227. openstackclient/tests/unit/volume/v2/test_volume_type.py +2 -4
  228. openstackclient/tests/unit/volume/v3/fakes.py +1 -0
  229. openstackclient/tests/unit/volume/v3/test_volume.py +60 -3
  230. openstackclient/tests/unit/volume/v3/test_volume_attachment.py +1 -1
  231. openstackclient/tests/unit/volume/v3/test_volume_backup.py +1 -5
  232. openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +55 -1
  233. openstackclient/tests/unit/volume/v3/test_volume_type.py +2 -4
  234. openstackclient/volume/client.py +7 -3
  235. openstackclient/volume/v2/backup_record.py +15 -6
  236. openstackclient/volume/v2/consistency_group.py +29 -17
  237. openstackclient/volume/v2/consistency_group_snapshot.py +25 -10
  238. openstackclient/volume/v2/qos_specs.py +28 -17
  239. openstackclient/volume/v2/service.py +17 -6
  240. openstackclient/volume/v2/volume.py +57 -29
  241. openstackclient/volume/v2/volume_backend.py +19 -6
  242. openstackclient/volume/v2/volume_backup.py +46 -20
  243. openstackclient/volume/v2/volume_host.py +6 -4
  244. openstackclient/volume/v2/volume_snapshot.py +50 -24
  245. openstackclient/volume/v2/volume_transfer_request.py +31 -13
  246. openstackclient/volume/v2/volume_type.py +43 -24
  247. openstackclient/volume/v3/block_storage_cleanup.py +11 -3
  248. openstackclient/volume/v3/block_storage_cluster.py +19 -7
  249. openstackclient/volume/v3/block_storage_log_level.py +15 -6
  250. openstackclient/volume/v3/block_storage_manage.py +10 -4
  251. openstackclient/volume/v3/block_storage_resource_filter.py +17 -5
  252. openstackclient/volume/v3/service.py +16 -6
  253. openstackclient/volume/v3/volume.py +89 -39
  254. openstackclient/volume/v3/volume_attachment.py +43 -21
  255. openstackclient/volume/v3/volume_backup.py +53 -24
  256. openstackclient/volume/v3/volume_group.py +23 -13
  257. openstackclient/volume/v3/volume_group_snapshot.py +32 -13
  258. openstackclient/volume/v3/volume_group_type.py +26 -13
  259. openstackclient/volume/v3/volume_message.py +15 -7
  260. openstackclient/volume/v3/volume_snapshot.py +69 -32
  261. openstackclient/volume/v3/volume_transfer_request.py +31 -13
  262. openstackclient/volume/v3/volume_type.py +42 -24
  263. {python_openstackclient-9.0.0.dist-info → python_openstackclient-10.0.0.dist-info}/METADATA +6 -6
  264. {python_openstackclient-9.0.0.dist-info → python_openstackclient-10.0.0.dist-info}/RECORD +271 -260
  265. {python_openstackclient-9.0.0.dist-info → python_openstackclient-10.0.0.dist-info}/WHEEL +1 -1
  266. {python_openstackclient-9.0.0.dist-info → python_openstackclient-10.0.0.dist-info}/entry_points.txt +53 -1
  267. {python_openstackclient-9.0.0.dist-info → python_openstackclient-10.0.0.dist-info}/licenses/AUTHORS +4 -0
  268. python_openstackclient-10.0.0.dist-info/pbr.json +1 -0
  269. openstackclient/api/image_v1.py +0 -69
  270. openstackclient/api/image_v2.py +0 -79
  271. openstackclient/network/v2/floating_ip_pool.py +0 -38
  272. openstackclient/tests/functional/image/v1/test_image.py +0 -97
  273. openstackclient/tests/unit/api/test_image_v1.py +0 -96
  274. openstackclient/tests/unit/api/test_image_v2.py +0 -96
  275. openstackclient/tests/unit/network/v2/test_floating_ip_compute.py +0 -248
  276. openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py +0 -49
  277. openstackclient/tests/unit/network/v2/test_floating_ip_pool_network.py +0 -39
  278. openstackclient/tests/unit/network/v2/test_network_compute.py +0 -404
  279. openstackclient/tests/unit/network/v2/test_security_group_compute.py +0 -392
  280. openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +0 -555
  281. python_openstackclient-9.0.0.dist-info/pbr.json +0 -1
  282. /openstackclient/{tests/functional/image/v1 → network/v2/bgpvpn}/__init__.py +0 -0
  283. {python_openstackclient-9.0.0.dist-info → python_openstackclient-10.0.0.dist-info}/licenses/LICENSE +0 -0
  284. {python_openstackclient-9.0.0.dist-info → python_openstackclient-10.0.0.dist-info}/top_level.txt +0 -0
@@ -20,14 +20,14 @@ from collections.abc import Callable
20
20
  import importlib
21
21
  import logging
22
22
  import sys
23
- import typing as ty
23
+ from typing import TYPE_CHECKING, Any, Protocol, TypeVar, runtime_checkable
24
24
 
25
25
  from osc_lib.cli import client_config
26
26
  from osc_lib import clientmanager
27
27
  from osc_lib import shell
28
28
  import stevedore
29
29
 
30
- if ty.TYPE_CHECKING:
30
+ if TYPE_CHECKING:
31
31
  from keystoneauth1 import access as ksa_access
32
32
  from openstack.compute.v2 import _proxy as compute_proxy
33
33
  from openstack.image.v2 import _proxy as image_proxy
@@ -37,7 +37,7 @@ if ty.TYPE_CHECKING:
37
37
 
38
38
  LOG = logging.getLogger(__name__)
39
39
 
40
- PLUGIN_MODULES: list[ty.Any] = []
40
+ PLUGIN_MODULES: list[Any] = []
41
41
 
42
42
  USER_AGENT = 'python-openstackclient'
43
43
 
@@ -50,7 +50,7 @@ class ClientManager(clientmanager.ClientManager):
50
50
  in osc-lib so we need to maintain a transition period.
51
51
  """
52
52
 
53
- if ty.TYPE_CHECKING:
53
+ if TYPE_CHECKING:
54
54
  # we know this will be set by us and will not be nullable
55
55
  auth_ref: ksa_access.AccessInfo
56
56
 
@@ -62,18 +62,18 @@ class ClientManager(clientmanager.ClientManager):
62
62
  # services...
63
63
  # TODO(stephenfin): We also need to migrate object storage...
64
64
  compute: compute_proxy.Proxy
65
- identity: ty.Any
65
+ identity: Any
66
66
  image: image_proxy.Proxy
67
67
  network: network_proxy.Proxy
68
68
  object_store: object_store_v1.APIv1
69
- volume: ty.Any
69
+ volume: Any
70
70
 
71
71
  def __init__(
72
72
  self,
73
- cli_options=None,
74
- api_version=None,
75
- pw_func=None,
76
- ):
73
+ cli_options: Any = None,
74
+ api_version: Any = None,
75
+ pw_func: Any = None,
76
+ ) -> None:
77
77
  super().__init__(
78
78
  cli_options=cli_options,
79
79
  api_version=api_version,
@@ -89,7 +89,7 @@ class ClientManager(clientmanager.ClientManager):
89
89
  # store original auth_type
90
90
  self._original_auth_type = cli_options.auth_type
91
91
 
92
- def setup_auth(self):
92
+ def setup_auth(self) -> None:
93
93
  """Set up authentication"""
94
94
 
95
95
  if self._auth_setup_completed:
@@ -125,7 +125,7 @@ class ClientManager(clientmanager.ClientManager):
125
125
 
126
126
  return super().setup_auth()
127
127
 
128
- def _fallback_load_auth_plugin(self, e):
128
+ def _fallback_load_auth_plugin(self, e: Exception) -> None:
129
129
  # NOTES(RuiChen): Hack to avoid auth plugins choking on data they don't
130
130
  # expect, delete fake token and endpoint, then try to
131
131
  # load auth plugin again with user specified options.
@@ -150,52 +150,77 @@ class ClientManager(clientmanager.ClientManager):
150
150
  else:
151
151
  raise e
152
152
 
153
- def is_network_endpoint_enabled(self):
153
+ def is_network_endpoint_enabled(self) -> bool:
154
154
  """Check if the network endpoint is enabled"""
155
155
  # NOTE(dtroyer): is_service_available() can also return None if
156
156
  # there is no Service Catalog, callers here are
157
157
  # not expecting that so fold None into True to
158
158
  # use Network API by default
159
- return self.is_service_available('network') is not False
159
+ return (
160
+ self.is_service_available(
161
+ 'network', self.region_name, self.interface
162
+ )
163
+ is not False
164
+ )
160
165
 
161
- def is_compute_endpoint_enabled(self):
166
+ def is_compute_endpoint_enabled(self) -> bool:
162
167
  """Check if Compute endpoint is enabled"""
163
- return self.is_service_available('compute') is not False
168
+ return (
169
+ self.is_service_available(
170
+ 'compute', self.region_name, self.interface
171
+ )
172
+ is not False
173
+ )
164
174
 
165
175
  # TODO(stephenfin): Drop volume_client argument in OSC 8.0 or later.
166
- def is_volume_endpoint_enabled(self, volume_client=None):
176
+ def is_volume_endpoint_enabled(self, volume_client: Any = None) -> bool:
167
177
  """Check if volume endpoint is enabled"""
168
178
  # We check against the service type and all aliases defined by the
169
179
  # Service Types Authority
170
180
  # https://service-types.openstack.org/service-types.json
171
181
  return (
172
- self.is_service_available('block-storage') is not False
173
- or self.is_service_available('volume') is not False
174
- or self.is_service_available('volumev3') is not False
175
- or self.is_service_available('volumev2') is not False
176
- or self.is_service_available('block-store') is not False
182
+ self.is_service_available(
183
+ 'block-storage', self.region_name, self.interface
184
+ )
185
+ is not False
186
+ or self.is_service_available(
187
+ 'volume', self.region_name, self.interface
188
+ )
189
+ is not False
190
+ or self.is_service_available(
191
+ 'volumev3', self.region_name, self.interface
192
+ )
193
+ is not False
194
+ or self.is_service_available(
195
+ 'volumev2', self.region_name, self.interface
196
+ )
197
+ is not False
198
+ or self.is_service_available(
199
+ 'block-store', self.region_name, self.interface
200
+ )
201
+ is not False
177
202
  )
178
203
 
179
204
 
180
205
  # Plugin Support
181
206
 
182
- ArgumentParserT = ty.TypeVar('ArgumentParserT', bound=argparse.ArgumentParser)
207
+ ArgumentParserT = TypeVar('ArgumentParserT', bound=argparse.ArgumentParser)
183
208
 
184
209
 
185
- @ty.runtime_checkable # Optional: allows usage with isinstance()
186
- class PluginModule(ty.Protocol):
210
+ @runtime_checkable # Optional: allows usage with isinstance()
211
+ class PluginModule(Protocol):
187
212
  DEFAULT_API_VERSION: str
188
213
  API_VERSION_OPTION: str
189
214
  API_NAME: str
190
215
  API_VERSIONS: tuple[str]
191
216
 
192
- make_client: Callable[..., ty.Any]
217
+ make_client: Callable[..., Any]
193
218
  build_option_parser: Callable[[ArgumentParserT], ArgumentParserT]
194
219
  check_api_version: Callable[[str], bool]
195
220
 
196
221
 
197
222
  def _on_load_failure_callback(
198
- manager: stevedore.ExtensionManager,
223
+ manager: stevedore.ExtensionManager[PluginModule],
199
224
  ep: importlib.metadata.EntryPoint,
200
225
  err: BaseException,
201
226
  ) -> None:
@@ -204,7 +229,7 @@ def _on_load_failure_callback(
204
229
  )
205
230
 
206
231
 
207
- def get_plugin_modules(group):
232
+ def get_plugin_modules(group: str) -> list[Any]:
208
233
  """Find plugin entry points"""
209
234
  mod_list = []
210
235
  mgr: stevedore.ExtensionManager[PluginModule]
@@ -238,7 +263,9 @@ def get_plugin_modules(group):
238
263
  return mod_list
239
264
 
240
265
 
241
- def build_plugin_option_parser(parser):
266
+ def build_plugin_option_parser(
267
+ parser: ArgumentParserT,
268
+ ) -> ArgumentParserT:
242
269
  """Add plugin options to the parser"""
243
270
 
244
271
  # Loop through extensions to get parser additions
@@ -13,6 +13,10 @@
13
13
 
14
14
  """Configuration action implementations"""
15
15
 
16
+ import argparse
17
+ from collections.abc import Iterable, Sequence
18
+ from typing import Any
19
+
16
20
  from keystoneauth1.loading import base
17
21
 
18
22
  from openstackclient import command
@@ -26,7 +30,7 @@ class ShowConfiguration(command.ShowOne):
26
30
 
27
31
  auth_required = False
28
32
 
29
- def get_parser(self, prog_name):
33
+ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
30
34
  parser = super().get_parser(prog_name)
31
35
  mask_group = parser.add_mutually_exclusive_group()
32
36
  mask_group.add_argument(
@@ -44,7 +48,9 @@ class ShowConfiguration(command.ShowOne):
44
48
  )
45
49
  return parser
46
50
 
47
- def take_action(self, parsed_args):
51
+ def take_action(
52
+ self, parsed_args: argparse.Namespace
53
+ ) -> tuple[Sequence[str], Iterable[Any]]:
48
54
  info = self.app.client_manager.get_configuration()
49
55
 
50
56
  # Assume a default secret list in case we do not have an auth_plugin
@@ -68,4 +74,5 @@ class ShowConfiguration(command.ShowOne):
68
74
  if secret_opt in info:
69
75
  info[secret_opt] = REDACTED
70
76
 
71
- return zip(*sorted(info.items()))
77
+ col_headers, col_data = zip(*sorted(info.items()))
78
+ return col_headers, col_data
@@ -15,7 +15,7 @@ import os
15
15
  from openstackclient.i18n import _
16
16
 
17
17
 
18
- def bool_from_str(value, strict=False):
18
+ def bool_from_str(value: bool | str, strict: bool = False) -> bool:
19
19
  true_strings = ('1', 't', 'true', 'on', 'y', 'yes')
20
20
  false_strings = ('0', 'f', 'false', 'off', 'n', 'no')
21
21
 
@@ -39,7 +39,7 @@ def bool_from_str(value, strict=False):
39
39
  raise ValueError(msg)
40
40
 
41
41
 
42
- def boolenv(*vars, default=False):
42
+ def boolenv(*vars: str, default: bool = False) -> bool:
43
43
  """Search for the first defined of possibly many bool-like env vars.
44
44
 
45
45
  Returns the first environment variable defined in vars, or returns the
@@ -15,7 +15,10 @@
15
15
 
16
16
  """Extension action implementations"""
17
17
 
18
+ import argparse
18
19
  import logging
20
+ from collections.abc import Iterable, Sequence
21
+ from typing import Any
19
22
 
20
23
  from osc_lib import utils
21
24
 
@@ -25,7 +28,9 @@ from openstackclient.i18n import _
25
28
  LOG = logging.getLogger(__name__)
26
29
 
27
30
 
28
- def _get_extension_columns(item):
31
+ def _get_extension_columns(
32
+ item: Any,
33
+ ) -> tuple[tuple[str, ...], tuple[str, ...]]:
29
34
  column_map = {
30
35
  'updated': 'updated_at',
31
36
  }
@@ -38,7 +43,7 @@ def _get_extension_columns(item):
38
43
  class ListExtension(command.Lister):
39
44
  _description = _("List API extensions")
40
45
 
41
- def get_parser(self, prog_name):
46
+ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
42
47
  parser = super().get_parser(prog_name)
43
48
  parser.add_argument(
44
49
  '--compute',
@@ -72,7 +77,9 @@ class ListExtension(command.Lister):
72
77
  )
73
78
  return parser
74
79
 
75
- def take_action(self, parsed_args):
80
+ def take_action(
81
+ self, parsed_args: argparse.Namespace
82
+ ) -> tuple[Sequence[str], Iterable[tuple[Any, ...]]]:
76
83
  columns: tuple[str, ...] = ('Name', 'Alias', 'Description')
77
84
  if parsed_args.long:
78
85
  columns += ('Namespace', 'Updated At', 'Links')
@@ -139,7 +146,7 @@ class ListExtension(command.Lister):
139
146
  class ShowExtension(command.ShowOne):
140
147
  _description = _("Show API extension")
141
148
 
142
- def get_parser(self, prog_name):
149
+ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
143
150
  parser = super().get_parser(prog_name)
144
151
  parser.add_argument(
145
152
  'extension',
@@ -152,7 +159,9 @@ class ShowExtension(command.ShowOne):
152
159
  )
153
160
  return parser
154
161
 
155
- def take_action(self, parsed_args):
162
+ def take_action(
163
+ self, parsed_args: argparse.Namespace
164
+ ) -> tuple[Sequence[str], Iterable[Any]]:
156
165
  client = self.app.client_manager.network
157
166
 
158
167
  extension = client.find_extension(
@@ -15,7 +15,10 @@
15
15
 
16
16
  """Limits Action Implementation"""
17
17
 
18
+ import argparse
18
19
  import itertools
20
+ from collections.abc import Iterable, Sequence
21
+ from typing import Any
19
22
 
20
23
  from osc_lib import utils
21
24
 
@@ -24,8 +27,8 @@ from openstackclient.i18n import _
24
27
  from openstackclient.identity import common as identity_common
25
28
 
26
29
 
27
- def _format_absolute_limit(absolute_limits):
28
- info = {}
30
+ def _format_absolute_limit(absolute_limits: Any) -> dict[str, Any]:
31
+ info: dict[str, Any] = {}
29
32
 
30
33
  for key in set(absolute_limits):
31
34
  if key in ('id', 'name', 'location'):
@@ -36,7 +39,7 @@ def _format_absolute_limit(absolute_limits):
36
39
  return info
37
40
 
38
41
 
39
- def _format_rate_limit(rate_limits):
42
+ def _format_rate_limit(rate_limits: Any) -> Any:
40
43
  # flatten this:
41
44
  #
42
45
  # {'uri': '<uri>', 'limit': [{'value': '<value>', ...], ...}
@@ -52,7 +55,7 @@ def _format_rate_limit(rate_limits):
52
55
  class ShowLimits(command.Lister):
53
56
  _description = _("Show compute and block storage limits")
54
57
 
55
- def get_parser(self, prog_name):
58
+ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
56
59
  parser = super().get_parser(prog_name)
57
60
  type_group = parser.add_mutually_exclusive_group(required=True)
58
61
  type_group.add_argument(
@@ -100,7 +103,9 @@ class ShowLimits(command.Lister):
100
103
  )
101
104
  return parser
102
105
 
103
- def take_action(self, parsed_args):
106
+ def take_action(
107
+ self, parsed_args: argparse.Namespace
108
+ ) -> tuple[Sequence[str], Iterable[tuple[Any, ...]]]:
104
109
  project_id = None
105
110
  if parsed_args.project is not None:
106
111
  identity_client = self.app.client_manager.identity
@@ -15,7 +15,10 @@
15
15
 
16
16
  """Module action implementation"""
17
17
 
18
+ import argparse
18
19
  import sys
20
+ from collections.abc import Iterable, Sequence
21
+ from typing import Any
19
22
 
20
23
  from osc_lib import utils
21
24
 
@@ -28,7 +31,7 @@ class ListCommand(command.Lister):
28
31
 
29
32
  auth_required = False
30
33
 
31
- def get_parser(self, prog_name):
34
+ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
32
35
  parser = super().get_parser(prog_name)
33
36
  parser.add_argument(
34
37
  '--group',
@@ -41,7 +44,9 @@ class ListCommand(command.Lister):
41
44
  )
42
45
  return parser
43
46
 
44
- def take_action(self, parsed_args):
47
+ def take_action(
48
+ self, parsed_args: argparse.Namespace
49
+ ) -> tuple[Sequence[str], Iterable[tuple[Any, ...]]]:
45
50
  cm = self.app.command_manager
46
51
  groups = cm.get_command_groups()
47
52
  groups = sorted(groups)
@@ -61,7 +66,7 @@ class ListCommand(command.Lister):
61
66
  # TODO(bapalm): Fix this when cliff properly supports
62
67
  # handling the detection rather than using the hard-code below.
63
68
  if parsed_args.formatter == 'table':
64
- command_names = utils.format_list(command_names, "\n") # type: ignore
69
+ command_names = utils.format_list(command_names, "\n") # type: ignore[assignment]
65
70
 
66
71
  commands.append((group, command_names))
67
72
 
@@ -73,7 +78,7 @@ class ListModule(command.ShowOne):
73
78
 
74
79
  auth_required = False
75
80
 
76
- def get_parser(self, prog_name):
81
+ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
77
82
  parser = super().get_parser(prog_name)
78
83
  parser.add_argument(
79
84
  '--all',
@@ -83,7 +88,9 @@ class ListModule(command.ShowOne):
83
88
  )
84
89
  return parser
85
90
 
86
- def take_action(self, parsed_args):
91
+ def take_action(
92
+ self, parsed_args: argparse.Namespace
93
+ ) -> tuple[Sequence[str], Iterable[Any]]:
87
94
  data = {}
88
95
  # Get module versions
89
96
  mods = sys.modules
@@ -117,4 +124,5 @@ class ListModule(command.ShowOne):
117
124
  # Catch all exceptions, just skip it
118
125
  pass
119
126
 
120
- return zip(*sorted(data.items()))
127
+ col_headers, col_data = zip(*sorted(data.items()))
128
+ return col_headers, col_data
@@ -10,6 +10,8 @@
10
10
  # License for the specific language governing permissions and limitations
11
11
  # under the License.
12
12
 
13
+ import argparse
14
+
13
15
  from osc_lib.cli import parseractions
14
16
 
15
17
  from openstackclient.i18n import _
@@ -19,7 +21,9 @@ from openstackclient.i18n import _
19
21
  # useful
20
22
 
21
23
 
22
- def add_marker_pagination_option_to_parser(parser):
24
+ def add_marker_pagination_option_to_parser(
25
+ parser: argparse.ArgumentParser,
26
+ ) -> None:
23
27
  """Add marker-based pagination options to the parser.
24
28
 
25
29
  APIs that use marker-based paging use the marker and limit query parameters
@@ -50,7 +54,9 @@ def add_marker_pagination_option_to_parser(parser):
50
54
  )
51
55
 
52
56
 
53
- def add_offset_pagination_option_to_parser(parser):
57
+ def add_offset_pagination_option_to_parser(
58
+ parser: argparse.ArgumentParser,
59
+ ) -> None:
54
60
  """Add offset-based pagination options to the parser.
55
61
 
56
62
  APIs that use offset-based paging use the offset and limit query parameters
@@ -14,6 +14,7 @@
14
14
  # under the License.
15
15
 
16
16
  import sys
17
+ from typing import Any
17
18
 
18
19
 
19
20
  class _ProgressBarBase:
@@ -28,24 +29,24 @@ class _ProgressBarBase:
28
29
  :note: The progress will be displayed only if sys.stdout is a tty.
29
30
  """
30
31
 
31
- def __init__(self, wrapped, totalsize):
32
+ def __init__(self, wrapped: Any, totalsize: int) -> None:
32
33
  self._wrapped = wrapped
33
34
  self._totalsize = float(totalsize)
34
35
  self._show_progress = sys.stdout.isatty() and self._totalsize != 0
35
- self._percent = 0
36
+ self._percent = 0.0
36
37
 
37
- def _display_progress_bar(self, size_read):
38
+ def _display_progress_bar(self, size_read: int) -> None:
38
39
  if self._show_progress:
39
40
  self._percent += size_read / self._totalsize
40
41
  # Output something like this: [==========> ] 49%
41
42
  sys.stdout.write(
42
43
  '\r[{:<30}] {:.0%}'.format(
43
- '=' * int(round(self._percent * 29)) + '>', self._percent
44
+ '=' * round(self._percent * 29) + '>', self._percent
44
45
  )
45
46
  )
46
47
  sys.stdout.flush()
47
48
 
48
- def __getattr__(self, attr):
49
+ def __getattr__(self, attr: str) -> Any:
49
50
  # Forward other attribute access to the wrapped object.
50
51
  return getattr(self._wrapped, attr)
51
52
 
@@ -57,7 +58,7 @@ class VerboseFileWrapper(_ProgressBarBase):
57
58
  wrapped file's read method is called.
58
59
  """
59
60
 
60
- def read(self, *args, **kwargs):
61
+ def read(self, *args: Any, **kwargs: Any) -> Any:
61
62
  data = self._wrapped.read(*args, **kwargs)
62
63
  if data:
63
64
  self._display_progress_bar(len(data))
@@ -13,13 +13,15 @@
13
13
  # under the License.
14
14
  #
15
15
 
16
+ import argparse
16
17
  import getpass
17
18
  import logging
18
19
  import os
19
20
  import queue
20
- import typing as ty
21
+ from typing import Any
21
22
 
22
23
  from cliff.formatters import table
24
+ from openstack import utils as sdk_utils
23
25
 
24
26
  from openstackclient import command
25
27
  from openstackclient.i18n import _
@@ -29,7 +31,7 @@ from openstackclient.identity import common as identity_common
29
31
  LOG = logging.getLogger(__name__)
30
32
 
31
33
 
32
- def ask_user_yesno(msg):
34
+ def ask_user_yesno(msg: str) -> bool:
33
35
  """Ask user Y/N question
34
36
 
35
37
  :param str msg: question text
@@ -46,7 +48,7 @@ def ask_user_yesno(msg):
46
48
  class ProjectCleanup(command.Command):
47
49
  _description = _("Clean resources associated with a project")
48
50
 
49
- def get_parser(self, prog_name):
51
+ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
50
52
  parser = super().get_parser(prog_name)
51
53
  action_group = parser.add_mutually_exclusive_group()
52
54
  action_group.add_argument(
@@ -89,7 +91,7 @@ class ProjectCleanup(command.Command):
89
91
  identity_common.add_project_domain_option_to_parser(parser)
90
92
  return parser
91
93
 
92
- def take_action(self, parsed_args):
94
+ def take_action(self, parsed_args: argparse.Namespace) -> None:
93
95
  connection = self.app.client_manager.sdk_connection
94
96
 
95
97
  if parsed_args.auth_project:
@@ -97,13 +99,17 @@ class ProjectCleanup(command.Command):
97
99
  # as-is
98
100
  pass
99
101
  elif parsed_args.project:
100
- project = connection.identity.find_project(
102
+ identity_client = sdk_utils.ensure_service_version(
103
+ connection.identity, '3'
104
+ )
105
+ project = identity_client.find_project(
101
106
  name_or_id=parsed_args.project, ignore_missing=False
102
107
  )
103
- connection = connection.connect_as_project(project)
108
+ # FIXME(stephenfin): The type in SDK is wrong
109
+ connection = connection.connect_as_project(project) # type: ignore
104
110
 
105
111
  if connection:
106
- status_queue: queue.Queue[ty.Any] = queue.Queue()
112
+ status_queue: queue.Queue[Any] = queue.Queue()
107
113
  parsed_args.max_width = int(
108
114
  os.environ.get('CLIFF_MAX_TERM_WIDTH', 0)
109
115
  )