python-openstackclient 7.4.0__py3-none-any.whl → 8.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 (234) hide show
  1. openstackclient/common/availability_zone.py +3 -6
  2. openstackclient/common/clientmanager.py +2 -1
  3. openstackclient/common/envvars.py +57 -0
  4. openstackclient/common/extension.py +3 -11
  5. openstackclient/common/limits.py +1 -1
  6. openstackclient/common/project_cleanup.py +3 -2
  7. openstackclient/common/quota.py +54 -28
  8. openstackclient/compute/client.py +2 -5
  9. openstackclient/compute/v2/agent.py +5 -5
  10. openstackclient/compute/v2/aggregate.py +17 -15
  11. openstackclient/compute/v2/console.py +3 -4
  12. openstackclient/compute/v2/flavor.py +14 -18
  13. openstackclient/compute/v2/host.py +3 -3
  14. openstackclient/compute/v2/hypervisor.py +10 -4
  15. openstackclient/compute/v2/hypervisor_stats.py +1 -1
  16. openstackclient/compute/v2/keypair.py +8 -10
  17. openstackclient/compute/v2/server.py +70 -112
  18. openstackclient/compute/v2/server_backup.py +1 -1
  19. openstackclient/compute/v2/server_event.py +7 -16
  20. openstackclient/compute/v2/server_group.py +6 -6
  21. openstackclient/compute/v2/server_image.py +1 -1
  22. openstackclient/compute/v2/server_migration.py +6 -6
  23. openstackclient/compute/v2/server_volume.py +4 -4
  24. openstackclient/compute/v2/service.py +9 -13
  25. openstackclient/compute/v2/usage.py +4 -6
  26. openstackclient/identity/client.py +2 -4
  27. openstackclient/identity/common.py +16 -17
  28. openstackclient/identity/v2_0/ec2creds.py +4 -3
  29. openstackclient/identity/v2_0/endpoint.py +12 -10
  30. openstackclient/identity/v2_0/project.py +6 -6
  31. openstackclient/identity/v2_0/role.py +1 -1
  32. openstackclient/identity/v2_0/service.py +7 -7
  33. openstackclient/identity/v2_0/user.py +6 -21
  34. openstackclient/identity/v3/access_rule.py +2 -5
  35. openstackclient/identity/v3/consumer.py +4 -3
  36. openstackclient/identity/v3/credential.py +6 -7
  37. openstackclient/identity/v3/domain.py +1 -1
  38. openstackclient/identity/v3/ec2creds.py +4 -3
  39. openstackclient/identity/v3/endpoint.py +104 -88
  40. openstackclient/identity/v3/endpoint_group.py +1 -1
  41. openstackclient/identity/v3/group.py +3 -4
  42. openstackclient/identity/v3/identity_provider.py +1 -2
  43. openstackclient/identity/v3/limit.py +4 -9
  44. openstackclient/identity/v3/mapping.py +4 -3
  45. openstackclient/identity/v3/policy.py +5 -8
  46. openstackclient/identity/v3/project.py +6 -6
  47. openstackclient/identity/v3/region.py +2 -5
  48. openstackclient/identity/v3/registered_limit.py +4 -8
  49. openstackclient/identity/v3/role.py +15 -16
  50. openstackclient/identity/v3/service.py +8 -8
  51. openstackclient/identity/v3/service_provider.py +3 -6
  52. openstackclient/identity/v3/tag.py +2 -2
  53. openstackclient/identity/v3/token.py +1 -2
  54. openstackclient/identity/v3/trust.py +74 -25
  55. openstackclient/identity/v3/user.py +9 -6
  56. openstackclient/image/client.py +2 -5
  57. openstackclient/image/v1/image.py +11 -15
  58. openstackclient/image/v2/cache.py +2 -4
  59. openstackclient/image/v2/image.py +30 -37
  60. openstackclient/image/v2/metadef_namespaces.py +4 -3
  61. openstackclient/image/v2/metadef_resource_type_association.py +1 -2
  62. openstackclient/image/v2/metadef_resource_types.py +1 -2
  63. openstackclient/locale/tr_TR/LC_MESSAGES/openstackclient.po +9 -1370
  64. openstackclient/network/client.py +4 -10
  65. openstackclient/network/common.py +16 -12
  66. openstackclient/network/utils.py +3 -3
  67. openstackclient/network/v2/address_group.py +5 -9
  68. openstackclient/network/v2/address_scope.py +2 -3
  69. openstackclient/network/v2/default_security_group_rule.py +1 -2
  70. openstackclient/network/v2/floating_ip.py +14 -21
  71. openstackclient/network/v2/floating_ip_port_forwarding.py +7 -7
  72. openstackclient/network/v2/ip_availability.py +1 -2
  73. openstackclient/network/v2/l3_conntrack_helper.py +8 -12
  74. openstackclient/network/v2/local_ip.py +24 -26
  75. openstackclient/network/v2/local_ip_association.py +4 -5
  76. openstackclient/network/v2/ndp_proxy.py +9 -10
  77. openstackclient/network/v2/network.py +12 -16
  78. openstackclient/network/v2/network_agent.py +29 -37
  79. openstackclient/network/v2/network_auto_allocated_topology.py +4 -5
  80. openstackclient/network/v2/network_flavor.py +1 -1
  81. openstackclient/network/v2/network_flavor_profile.py +5 -5
  82. openstackclient/network/v2/network_meter.py +3 -3
  83. openstackclient/network/v2/network_meter_rule.py +5 -8
  84. openstackclient/network/v2/network_qos_policy.py +4 -4
  85. openstackclient/network/v2/network_qos_rule.py +4 -5
  86. openstackclient/network/v2/network_rbac.py +4 -4
  87. openstackclient/network/v2/network_segment.py +6 -7
  88. openstackclient/network/v2/network_segment_range.py +16 -20
  89. openstackclient/network/v2/network_trunk.py +24 -16
  90. openstackclient/network/v2/port.py +28 -29
  91. openstackclient/network/v2/router.py +52 -41
  92. openstackclient/network/v2/security_group.py +8 -15
  93. openstackclient/network/v2/security_group_rule.py +9 -10
  94. openstackclient/network/v2/subnet.py +31 -30
  95. openstackclient/network/v2/subnet_pool.py +4 -4
  96. openstackclient/object/client.py +2 -3
  97. openstackclient/object/v1/container.py +2 -3
  98. openstackclient/object/v1/object.py +2 -9
  99. openstackclient/shell.py +22 -5
  100. openstackclient/tests/functional/base.py +2 -2
  101. openstackclient/tests/functional/common/test_quota.py +3 -1
  102. openstackclient/tests/functional/compute/v2/common.py +12 -6
  103. openstackclient/tests/functional/compute/v2/test_server.py +2 -3
  104. openstackclient/tests/functional/compute/v2/test_server_event.py +1 -1
  105. openstackclient/tests/functional/identity/v2/test_user.py +1 -1
  106. openstackclient/tests/functional/identity/v3/common.py +3 -8
  107. openstackclient/tests/functional/identity/v3/test_application_credential.py +10 -10
  108. openstackclient/tests/functional/identity/v3/test_endpoint.py +3 -3
  109. openstackclient/tests/functional/identity/v3/test_group.py +3 -3
  110. openstackclient/tests/functional/identity/v3/test_idp.py +3 -7
  111. openstackclient/tests/functional/identity/v3/test_limit.py +4 -4
  112. openstackclient/tests/functional/identity/v3/test_project.py +5 -14
  113. openstackclient/tests/functional/identity/v3/test_region.py +1 -3
  114. openstackclient/tests/functional/identity/v3/test_registered_limit.py +3 -3
  115. openstackclient/tests/functional/identity/v3/test_role.py +1 -1
  116. openstackclient/tests/functional/identity/v3/test_role_assignment.py +13 -31
  117. openstackclient/tests/functional/identity/v3/test_service_provider.py +3 -7
  118. openstackclient/tests/functional/identity/v3/test_user.py +8 -8
  119. openstackclient/tests/functional/network/v2/common.py +7 -3
  120. openstackclient/tests/functional/network/v2/test_address_group.py +4 -0
  121. openstackclient/tests/functional/network/v2/test_l3_conntrack_helper.py +15 -11
  122. openstackclient/tests/functional/network/v2/test_local_ip.py +4 -0
  123. openstackclient/tests/functional/network/v2/test_network_meter_rule.py +2 -2
  124. openstackclient/tests/functional/network/v2/test_network_ndp_proxy.py +2 -3
  125. openstackclient/tests/functional/network/v2/test_network_rbac.py +2 -2
  126. openstackclient/tests/functional/network/v2/test_network_trunk.py +1 -1
  127. openstackclient/tests/functional/network/v2/test_port.py +17 -7
  128. openstackclient/tests/functional/network/v2/test_router.py +42 -0
  129. openstackclient/tests/functional/network/v2/test_subnet_pool.py +4 -0
  130. openstackclient/tests/unit/api/test_compute_v2.py +67 -87
  131. openstackclient/tests/unit/common/test_availability_zone.py +6 -14
  132. openstackclient/tests/unit/common/test_command.py +1 -1
  133. openstackclient/tests/unit/common/test_extension.py +5 -7
  134. openstackclient/tests/unit/common/test_limits.py +1 -1
  135. openstackclient/tests/unit/common/test_project_cleanup.py +5 -6
  136. openstackclient/tests/unit/common/test_quota.py +51 -28
  137. openstackclient/tests/unit/compute/v2/fakes.py +4 -10
  138. openstackclient/tests/unit/compute/v2/test_agent.py +16 -16
  139. openstackclient/tests/unit/compute/v2/test_aggregate.py +56 -60
  140. openstackclient/tests/unit/compute/v2/test_console.py +16 -16
  141. openstackclient/tests/unit/compute/v2/test_flavor.py +71 -71
  142. openstackclient/tests/unit/compute/v2/test_host.py +8 -8
  143. openstackclient/tests/unit/compute/v2/test_hypervisor.py +22 -30
  144. openstackclient/tests/unit/compute/v2/test_hypervisor_stats.py +2 -2
  145. openstackclient/tests/unit/compute/v2/test_keypair.py +24 -24
  146. openstackclient/tests/unit/compute/v2/test_server.py +524 -560
  147. openstackclient/tests/unit/compute/v2/test_server_backup.py +5 -7
  148. openstackclient/tests/unit/compute/v2/test_server_event.py +16 -18
  149. openstackclient/tests/unit/compute/v2/test_server_group.py +25 -31
  150. openstackclient/tests/unit/compute/v2/test_server_image.py +6 -8
  151. openstackclient/tests/unit/compute/v2/test_server_migration.py +37 -37
  152. openstackclient/tests/unit/compute/v2/test_server_volume.py +12 -12
  153. openstackclient/tests/unit/compute/v2/test_service.py +39 -45
  154. openstackclient/tests/unit/compute/v2/test_usage.py +5 -5
  155. openstackclient/tests/unit/identity/v2_0/fakes.py +1 -1
  156. openstackclient/tests/unit/identity/v3/test_access_rule.py +1 -3
  157. openstackclient/tests/unit/identity/v3/test_application_credential.py +1 -1
  158. openstackclient/tests/unit/identity/v3/test_endpoint.py +167 -172
  159. openstackclient/tests/unit/identity/v3/test_mappings.py +2 -2
  160. openstackclient/tests/unit/identity/v3/test_trust.py +5 -2
  161. openstackclient/tests/unit/identity/v3/test_user.py +16 -0
  162. openstackclient/tests/unit/image/v1/fakes.py +2 -2
  163. openstackclient/tests/unit/image/v2/test_image.py +39 -1
  164. openstackclient/tests/unit/integ/cli/test_shell.py +1 -2
  165. openstackclient/tests/unit/network/test_common.py +2 -2
  166. openstackclient/tests/unit/network/v2/test_floating_ip_compute.py +8 -14
  167. openstackclient/tests/unit/network/v2/test_floating_ip_network.py +49 -35
  168. openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py +1 -1
  169. openstackclient/tests/unit/network/v2/test_network_compute.py +11 -11
  170. openstackclient/tests/unit/network/v2/test_network_trunk.py +2 -2
  171. openstackclient/tests/unit/network/v2/test_port.py +4 -5
  172. openstackclient/tests/unit/network/v2/test_router.py +63 -0
  173. openstackclient/tests/unit/network/v2/test_security_group_compute.py +11 -19
  174. openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +14 -14
  175. openstackclient/tests/unit/object/v1/test_object_all.py +4 -3
  176. openstackclient/tests/unit/test_shell.py +16 -13
  177. openstackclient/tests/unit/volume/v2/test_volume.py +1 -1
  178. openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py +1 -1
  179. openstackclient/tests/unit/volume/v3/fakes.py +2 -8
  180. openstackclient/tests/unit/volume/v3/test_volume.py +1 -1
  181. openstackclient/tests/unit/volume/v3/test_volume_attachment.py +3 -3
  182. openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +1 -2
  183. openstackclient/tests/unit/volume/v3/test_volume_transfer_request.py +1 -1
  184. openstackclient/volume/client.py +1 -3
  185. openstackclient/volume/v2/consistency_group.py +4 -8
  186. openstackclient/volume/v2/consistency_group_snapshot.py +1 -2
  187. openstackclient/volume/v2/qos_specs.py +1 -2
  188. openstackclient/volume/v2/volume.py +8 -16
  189. openstackclient/volume/v2/volume_backup.py +6 -7
  190. openstackclient/volume/v2/volume_snapshot.py +8 -9
  191. openstackclient/volume/v2/volume_transfer_request.py +0 -3
  192. openstackclient/volume/v2/volume_type.py +10 -21
  193. openstackclient/volume/v3/block_storage_cluster.py +3 -3
  194. openstackclient/volume/v3/block_storage_manage.py +1 -3
  195. openstackclient/volume/v3/volume.py +18 -19
  196. openstackclient/volume/v3/volume_attachment.py +3 -2
  197. openstackclient/volume/v3/volume_backup.py +7 -8
  198. openstackclient/volume/v3/volume_group.py +2 -1
  199. openstackclient/volume/v3/volume_group_snapshot.py +2 -1
  200. openstackclient/volume/v3/volume_snapshot.py +4 -3
  201. openstackclient/volume/v3/volume_type.py +10 -21
  202. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/AUTHORS +3 -0
  203. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/METADATA +7 -13
  204. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/RECORD +209 -232
  205. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/WHEEL +1 -1
  206. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/entry_points.txt +0 -41
  207. python_openstackclient-8.0.0.dist-info/pbr.json +1 -0
  208. openstackclient/tests/functional/volume/v1/__init__.py +0 -0
  209. openstackclient/tests/functional/volume/v1/common.py +0 -35
  210. openstackclient/tests/functional/volume/v1/test_qos.py +0 -100
  211. openstackclient/tests/functional/volume/v1/test_service.py +0 -76
  212. openstackclient/tests/functional/volume/v1/test_snapshot.py +0 -232
  213. openstackclient/tests/functional/volume/v1/test_transfer_request.py +0 -111
  214. openstackclient/tests/functional/volume/v1/test_volume.py +0 -228
  215. openstackclient/tests/functional/volume/v1/test_volume_type.py +0 -213
  216. openstackclient/tests/unit/volume/v1/__init__.py +0 -0
  217. openstackclient/tests/unit/volume/v1/fakes.py +0 -615
  218. openstackclient/tests/unit/volume/v1/test_qos_specs.py +0 -471
  219. openstackclient/tests/unit/volume/v1/test_service.py +0 -295
  220. openstackclient/tests/unit/volume/v1/test_transfer_request.py +0 -380
  221. openstackclient/tests/unit/volume/v1/test_type.py +0 -633
  222. openstackclient/tests/unit/volume/v1/test_volume.py +0 -1447
  223. openstackclient/tests/unit/volume/v1/test_volume_backup.py +0 -435
  224. openstackclient/volume/v1/__init__.py +0 -0
  225. openstackclient/volume/v1/qos_specs.py +0 -377
  226. openstackclient/volume/v1/service.py +0 -136
  227. openstackclient/volume/v1/volume.py +0 -734
  228. openstackclient/volume/v1/volume_backup.py +0 -302
  229. openstackclient/volume/v1/volume_snapshot.py +0 -433
  230. openstackclient/volume/v1/volume_transfer_request.py +0 -200
  231. openstackclient/volume/v1/volume_type.py +0 -520
  232. python_openstackclient-7.4.0.dist-info/pbr.json +0 -1
  233. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/LICENSE +0 -0
  234. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.0.0.dist-info}/top_level.txt +0 -0
@@ -156,9 +156,10 @@ class DeleteEC2Creds(command.Command):
156
156
 
157
157
  if result > 0:
158
158
  total = len(parsed_args.access_key)
159
- msg = _(
160
- "%(result)s of %(total)s EC2 keys failed " "to delete."
161
- ) % {'result': result, 'total': total}
159
+ msg = _("%(result)s of %(total)s EC2 keys failed to delete.") % {
160
+ 'result': result,
161
+ 'total': total,
162
+ }
162
163
  raise exceptions.CommandError(msg)
163
164
 
164
165
 
@@ -28,11 +28,31 @@ from openstackclient.identity import common
28
28
  LOG = logging.getLogger(__name__)
29
29
 
30
30
 
31
- def get_service_name(service):
32
- if hasattr(service, 'name'):
33
- return service.name
34
- else:
35
- return ''
31
+ def _format_endpoint(endpoint, service):
32
+ columns = (
33
+ 'is_enabled',
34
+ 'id',
35
+ 'interface',
36
+ 'region_id',
37
+ 'region_id',
38
+ 'service_id',
39
+ 'url',
40
+ )
41
+ column_headers = (
42
+ 'enabled',
43
+ 'id',
44
+ 'interface',
45
+ 'region',
46
+ 'region_id',
47
+ 'service_id',
48
+ 'url',
49
+ 'service_name',
50
+ 'service_type',
51
+ )
52
+
53
+ data = utils.get_item_properties(endpoint, columns)
54
+ data += (getattr(service, 'name', ''), service.type)
55
+ return column_headers, data
36
56
 
37
57
 
38
58
  class AddProjectToEndpoint(command.Command):
@@ -44,15 +64,13 @@ class AddProjectToEndpoint(command.Command):
44
64
  'endpoint',
45
65
  metavar='<endpoint>',
46
66
  help=_(
47
- 'Endpoint to associate with ' 'specified project (name or ID)'
67
+ 'Endpoint to associate with specified project (name or ID)'
48
68
  ),
49
69
  )
50
70
  parser.add_argument(
51
71
  'project',
52
72
  metavar='<project>',
53
- help=_(
54
- 'Project to associate with ' 'specified endpoint name or ID)'
55
- ),
73
+ help=_('Project to associate with specified endpoint name or ID)'),
56
74
  )
57
75
  common.add_project_domain_option_to_parser(parser)
58
76
  return parser
@@ -114,23 +132,23 @@ class CreateEndpoint(command.ShowOne):
114
132
  return parser
115
133
 
116
134
  def take_action(self, parsed_args):
117
- identity_client = self.app.client_manager.identity
118
- service = common.find_service(identity_client, parsed_args.service)
119
-
120
- endpoint = identity_client.endpoints.create(
121
- service=service.id,
122
- url=parsed_args.url,
123
- interface=parsed_args.interface,
124
- region=parsed_args.region,
125
- enabled=parsed_args.enabled,
126
- )
135
+ identity_client = self.app.client_manager.sdk_connection.identity
136
+ service = common.find_service_sdk(identity_client, parsed_args.service)
137
+
138
+ kwargs = {}
139
+
140
+ kwargs['service_id'] = service.id
141
+ kwargs['url'] = parsed_args.url
142
+ kwargs['interface'] = parsed_args.interface
143
+ kwargs['is_enabled'] = parsed_args.enabled
144
+
145
+ if parsed_args.region:
146
+ region = identity_client.get_region(parsed_args.region)
147
+ kwargs['region_id'] = region.id
127
148
 
128
- info = {}
129
- endpoint._info.pop('links')
130
- info.update(endpoint._info)
131
- info['service_name'] = get_service_name(service)
132
- info['service_type'] = service.type
133
- return zip(*sorted(info.items()))
149
+ endpoint = identity_client.create_endpoint(**kwargs)
150
+
151
+ return _format_endpoint(endpoint, service=service)
134
152
 
135
153
 
136
154
  class DeleteEndpoint(command.Command):
@@ -147,14 +165,12 @@ class DeleteEndpoint(command.Command):
147
165
  return parser
148
166
 
149
167
  def take_action(self, parsed_args):
150
- identity_client = self.app.client_manager.identity
168
+ identity_client = self.app.client_manager.sdk_connection.identity
151
169
  result = 0
152
170
  for i in parsed_args.endpoint:
153
171
  try:
154
- endpoint_id = utils.find_resource(
155
- identity_client.endpoints, i
156
- ).id
157
- identity_client.endpoints.delete(endpoint_id)
172
+ endpoint_id = identity_client.find_endpoint(i).id
173
+ identity_client.delete_endpoint(endpoint_id)
158
174
  except Exception as e:
159
175
  result += 1
160
176
  LOG.error(
@@ -167,9 +183,10 @@ class DeleteEndpoint(command.Command):
167
183
 
168
184
  if result > 0:
169
185
  total = len(parsed_args.endpoint)
170
- msg = _(
171
- "%(result)s of %(total)s endpoints failed " "to delete."
172
- ) % {'result': result, 'total': total}
186
+ msg = _("%(result)s of %(total)s endpoints failed to delete.") % {
187
+ 'result': result,
188
+ 'total': total,
189
+ }
173
190
  raise exceptions.CommandError(msg)
174
191
 
175
192
 
@@ -209,28 +226,24 @@ class ListEndpoint(command.Lister):
209
226
  return parser
210
227
 
211
228
  def take_action(self, parsed_args):
212
- identity_client = self.app.client_manager.identity
229
+ identity_client = self.app.client_manager.sdk_connection.identity
213
230
 
214
231
  endpoint = None
215
232
  if parsed_args.endpoint:
216
- endpoint = utils.find_resource(
217
- identity_client.endpoints, parsed_args.endpoint
218
- )
233
+ endpoint = identity_client.find_endpoint(parsed_args.endpoint)
219
234
  project = None
220
235
  if parsed_args.project:
221
- project = common.find_project(
222
- identity_client,
236
+ project = identity_client.find_project(
223
237
  parsed_args.project,
224
238
  parsed_args.project_domain,
225
239
  )
226
240
 
227
241
  if endpoint:
228
- columns = ('ID', 'Name')
229
- data = identity_client.endpoint_filter.list_projects_for_endpoint(
230
- endpoint=endpoint.id
231
- )
242
+ column_headers: tuple[str, ...] = ('ID', 'Name')
243
+ columns: tuple[str, ...] = ('id', 'name')
244
+ data = identity_client.endpoint_projects(endpoint=endpoint.id)
232
245
  else:
233
- columns = (
246
+ column_headers = (
234
247
  'ID',
235
248
  'Region',
236
249
  'Service Name',
@@ -239,37 +252,41 @@ class ListEndpoint(command.Lister):
239
252
  'Interface',
240
253
  'URL',
241
254
  )
255
+ columns = (
256
+ 'id',
257
+ 'region_id',
258
+ 'service_name',
259
+ 'service_type',
260
+ 'is_enabled',
261
+ 'interface',
262
+ 'url',
263
+ )
242
264
  kwargs = {}
243
265
  if parsed_args.service:
244
- service = common.find_service(
266
+ service = common.find_service_sdk(
245
267
  identity_client, parsed_args.service
246
268
  )
247
- kwargs['service'] = service.id
269
+ kwargs['service_id'] = service.id
248
270
  if parsed_args.interface:
249
271
  kwargs['interface'] = parsed_args.interface
250
272
  if parsed_args.region:
251
- kwargs['region'] = parsed_args.region
273
+ region = identity_client.get_region(parsed_args.region)
274
+ kwargs['region_id'] = region.id
252
275
 
253
276
  if project:
254
- data = (
255
- identity_client.endpoint_filter.list_endpoints_for_project(
256
- project=project.id
257
- )
277
+ data = list(
278
+ identity_client.project_endpoints(project=project.id)
258
279
  )
259
280
  else:
260
- data = identity_client.endpoints.list(**kwargs)
261
-
262
- service_list = identity_client.services.list()
281
+ data = list(identity_client.endpoints(**kwargs))
263
282
 
264
283
  for ep in data:
265
- service = common.find_service_in_list(
266
- service_list, ep.service_id
267
- )
268
- ep.service_name = get_service_name(service)
284
+ service = identity_client.find_service(ep.service_id)
285
+ ep.service_name = getattr(service, 'name', '')
269
286
  ep.service_type = service.type
270
287
 
271
288
  return (
272
- columns,
289
+ column_headers,
273
290
  (
274
291
  utils.get_item_properties(
275
292
  s,
@@ -290,14 +307,14 @@ class RemoveProjectFromEndpoint(command.Command):
290
307
  'endpoint',
291
308
  metavar='<endpoint>',
292
309
  help=_(
293
- 'Endpoint to dissociate from ' 'specified project (name or ID)'
310
+ 'Endpoint to dissociate from specified project (name or ID)'
294
311
  ),
295
312
  )
296
313
  parser.add_argument(
297
314
  'project',
298
315
  metavar='<project>',
299
316
  help=_(
300
- 'Project to dissociate from ' 'specified endpoint name or ID)'
317
+ 'Project to dissociate from specified endpoint name or ID)'
301
318
  ),
302
319
  )
303
320
  common.add_project_domain_option_to_parser(parser)
@@ -364,28 +381,34 @@ class SetEndpoint(command.Command):
364
381
  return parser
365
382
 
366
383
  def take_action(self, parsed_args):
367
- identity_client = self.app.client_manager.identity
368
- endpoint = utils.find_resource(
369
- identity_client.endpoints, parsed_args.endpoint
370
- )
384
+ identity_client = self.app.client_manager.sdk_connection.identity
385
+ endpoint = identity_client.find_endpoint(parsed_args.endpoint)
386
+
387
+ kwargs = {}
371
388
 
372
- service_id = None
373
389
  if parsed_args.service:
374
- service = common.find_service(identity_client, parsed_args.service)
375
- service_id = service.id
376
- enabled = None
390
+ service = common.find_service_sdk(
391
+ identity_client, parsed_args.service
392
+ )
393
+ kwargs['service_id'] = service.id
394
+
377
395
  if parsed_args.enabled:
378
- enabled = True
396
+ kwargs['is_enabled'] = True
379
397
  if parsed_args.disabled:
380
- enabled = False
398
+ kwargs['is_enabled'] = False
399
+
400
+ if parsed_args.url:
401
+ kwargs['url'] = parsed_args.url
402
+
403
+ if parsed_args.interface:
404
+ kwargs['interface'] = parsed_args.interface
381
405
 
382
- identity_client.endpoints.update(
406
+ if parsed_args.region:
407
+ kwargs['region_id'] = parsed_args.region
408
+
409
+ identity_client.update_endpoint(
383
410
  endpoint.id,
384
- service=service_id,
385
- url=parsed_args.url,
386
- interface=parsed_args.interface,
387
- region=parsed_args.region,
388
- enabled=enabled,
411
+ **kwargs,
389
412
  )
390
413
 
391
414
 
@@ -405,16 +428,9 @@ class ShowEndpoint(command.ShowOne):
405
428
  return parser
406
429
 
407
430
  def take_action(self, parsed_args):
408
- identity_client = self.app.client_manager.identity
409
- endpoint = utils.find_resource(
410
- identity_client.endpoints, parsed_args.endpoint
411
- )
431
+ identity_client = self.app.client_manager.sdk_connection.identity
432
+ endpoint = identity_client.find_endpoint(parsed_args.endpoint)
412
433
 
413
- service = common.find_service(identity_client, endpoint.service_id)
434
+ service = common.find_service_sdk(identity_client, endpoint.service_id)
414
435
 
415
- info = {}
416
- endpoint._info.pop('links')
417
- info.update(endpoint._info)
418
- info['service_name'] = get_service_name(service)
419
- info['service_type'] = service.type
420
- return zip(*sorted(info.items()))
436
+ return _format_endpoint(endpoint, service)
@@ -168,7 +168,7 @@ class DeleteEndpointGroup(command.Command):
168
168
  if result > 0:
169
169
  total = len(parsed_args.endpointgroup)
170
170
  msg = _(
171
- "%(result)s of %(total)s endpointgroups failed " "to delete."
171
+ "%(result)s of %(total)s endpointgroups failed to delete."
172
172
  ) % {'result': result, 'total': total}
173
173
  raise exceptions.CommandError(msg)
174
174
 
@@ -230,7 +230,7 @@ class DeleteGroup(command.Command):
230
230
 
231
231
  if errors > 0:
232
232
  total = len(parsed_args.groups)
233
- msg = _("%(errors)s of %(total)s groups failed " "to delete.") % {
233
+ msg = _("%(errors)s of %(total)s groups failed to delete.") % {
234
234
  'errors': errors,
235
235
  'total': total,
236
236
  }
@@ -278,10 +278,9 @@ class ListGroup(command.Lister):
278
278
  user = None
279
279
 
280
280
  # List groups
281
+ columns: tuple[str, ...] = ('ID', 'Name')
281
282
  if parsed_args.long:
282
- columns = ('ID', 'Name', 'Domain ID', 'Description')
283
- else:
284
- columns = ('ID', 'Name')
283
+ columns += ('Domain ID', 'Description')
285
284
  data = identity_client.groups.list(
286
285
  domain=domain,
287
286
  user=user,
@@ -174,8 +174,7 @@ class DeleteIdentityProvider(command.Command):
174
174
  if result > 0:
175
175
  total = len(parsed_args.identity_provider)
176
176
  msg = _(
177
- "%(result)s of %(total)s identity providers failed"
178
- " to delete."
177
+ "%(result)s of %(total)s identity providers failed to delete."
179
178
  ) % {'result': result, 'total': total}
180
179
  raise exceptions.CommandError(msg)
181
180
 
@@ -77,8 +77,7 @@ class CreateLimit(command.ShowOne):
77
77
  )
78
78
  region = None
79
79
  if parsed_args.region:
80
- val = getattr(parsed_args, 'region', None)
81
- if 'None' not in val:
80
+ if 'None' not in parsed_args.region:
82
81
  # NOTE (vishakha): Due to bug #1799153 and for any another
83
82
  # related case where GET resource API does not support the
84
83
  # filter by name, osc_lib.utils.find_resource() method cannot
@@ -149,11 +148,7 @@ class ListLimit(command.Lister):
149
148
  )
150
149
  region = None
151
150
  if parsed_args.region:
152
- region = utils.find_resource(
153
- identity_client.regions, parsed_args.region
154
- )
155
- val = getattr(parsed_args, 'region', None)
156
- if 'None' not in val:
151
+ if 'None' not in parsed_args.region:
157
152
  # NOTE (vishakha): Due to bug #1799153 and for any another
158
153
  # related case where GET resource API does not support the
159
154
  # filter by name, osc_lib.utils.find_resource() method cannot
@@ -281,13 +276,13 @@ class DeleteLimit(command.Command):
281
276
  except Exception as e:
282
277
  errors += 1
283
278
  LOG.error(
284
- _("Failed to delete limit with ID " "'%(id)s': %(e)s"),
279
+ _("Failed to delete limit with ID '%(id)s': %(e)s"),
285
280
  {'id': limit_id, 'e': e},
286
281
  )
287
282
 
288
283
  if errors > 0:
289
284
  total = len(parsed_args.limit_id)
290
- msg = _("%(errors)s of %(total)s limits failed to " "delete.") % {
285
+ msg = _("%(errors)s of %(total)s limits failed to delete.") % {
291
286
  'errors': errors,
292
287
  'total': total,
293
288
  }
@@ -161,9 +161,10 @@ class DeleteMapping(command.Command):
161
161
 
162
162
  if result > 0:
163
163
  total = len(parsed_args.mapping)
164
- msg = _(
165
- "%(result)s of %(total)s mappings failed " "to delete."
166
- ) % {'result': result, 'total': total}
164
+ msg = _("%(result)s of %(total)s mappings failed to delete.") % {
165
+ 'result': result,
166
+ 'total': total,
167
+ }
167
168
  raise exceptions.CommandError(msg)
168
169
 
169
170
 
@@ -92,9 +92,7 @@ class DeletePolicy(command.Command):
92
92
 
93
93
  if result > 0:
94
94
  total = len(parsed_args.policy)
95
- msg = _(
96
- "%(result)s of %(total)s policies failed " "to delete."
97
- ) % {
95
+ msg = _("%(result)s of %(total)s policies failed to delete.") % {
98
96
  'result': result,
99
97
  'total': total,
100
98
  }
@@ -115,12 +113,11 @@ class ListPolicy(command.Lister):
115
113
  return parser
116
114
 
117
115
  def take_action(self, parsed_args):
116
+ columns: tuple[str, ...] = ('ID', 'Type')
117
+ column_headers: tuple[str, ...] = columns
118
118
  if parsed_args.long:
119
- columns = ('ID', 'Type', 'Blob')
120
- column_headers = ('ID', 'Type', 'Rules')
121
- else:
122
- columns = ('ID', 'Type')
123
- column_headers = columns
119
+ columns += ('Blob',)
120
+ column_headers += ('Rules',)
124
121
  data = self.app.client_manager.identity.policies.list()
125
122
  return (
126
123
  column_headers,
@@ -190,9 +190,10 @@ class DeleteProject(command.Command):
190
190
 
191
191
  if errors > 0:
192
192
  total = len(parsed_args.projects)
193
- msg = _(
194
- "%(errors)s of %(total)s projects failed " "to delete."
195
- ) % {'errors': errors, 'total': total}
193
+ msg = _("%(errors)s of %(total)s projects failed to delete.") % {
194
+ 'errors': errors,
195
+ 'total': total,
196
+ }
196
197
  raise exceptions.CommandError(msg)
197
198
 
198
199
 
@@ -244,10 +245,9 @@ class ListProject(command.Lister):
244
245
 
245
246
  def take_action(self, parsed_args):
246
247
  identity_client = self.app.client_manager.identity
248
+ columns: tuple[str, ...] = ('ID', 'Name')
247
249
  if parsed_args.long:
248
- columns = ('ID', 'Name', 'Domain ID', 'Description', 'Enabled')
249
- else:
250
- columns = ('ID', 'Name')
250
+ columns += ('Domain ID', 'Description', 'Enabled')
251
251
  kwargs = {}
252
252
 
253
253
  domain_id = None
@@ -92,16 +92,13 @@ class DeleteRegion(command.Command):
92
92
  except Exception as e:
93
93
  result += 1
94
94
  LOG.error(
95
- _(
96
- "Failed to delete region with "
97
- "ID '%(region)s': %(e)s"
98
- ),
95
+ _("Failed to delete region with ID '%(region)s': %(e)s"),
99
96
  {'region': i, 'e': e},
100
97
  )
101
98
 
102
99
  if result > 0:
103
100
  total = len(parsed_args.region)
104
- msg = _("%(result)s of %(total)s regions failed " "to delete.") % {
101
+ msg = _("%(result)s of %(total)s regions failed to delete.") % {
105
102
  'result': result,
106
103
  'total': total,
107
104
  }
@@ -68,8 +68,7 @@ class CreateRegisteredLimit(command.ShowOne):
68
68
  )
69
69
  region = None
70
70
  if parsed_args.region:
71
- val = getattr(parsed_args, 'region', None)
72
- if 'None' not in val:
71
+ if 'None' not in parsed_args.region:
73
72
  # NOTE (vishakha): Due to bug #1799153 and for any another
74
73
  # related case where GET resource API does not support the
75
74
  # filter by name, osc_lib.utils.find_resource() method cannot
@@ -137,8 +136,7 @@ class DeleteRegisteredLimit(command.Command):
137
136
  if errors > 0:
138
137
  total = len(parsed_args.registered_limit_id)
139
138
  msg = _(
140
- "%(errors)s of %(total)s registered limits failed to "
141
- "delete."
139
+ "%(errors)s of %(total)s registered limits failed to delete."
142
140
  ) % {'errors': errors, 'total': total}
143
141
  raise exceptions.CommandError(msg)
144
142
 
@@ -176,8 +174,7 @@ class ListRegisteredLimit(command.Lister):
176
174
  )
177
175
  region = None
178
176
  if parsed_args.region:
179
- val = getattr(parsed_args, 'region', None)
180
- if 'None' not in val:
177
+ if 'None' not in parsed_args.region:
181
178
  # NOTE (vishakha): Due to bug #1799153 and for any another
182
179
  # related case where GET resource API does not support the
183
180
  # filter by name, osc_lib.utils.find_resource() method cannot
@@ -281,8 +278,7 @@ class SetRegisteredLimit(command.ShowOne):
281
278
 
282
279
  region = None
283
280
  if parsed_args.region:
284
- val = getattr(parsed_args, 'region', None)
285
- if 'None' not in val:
281
+ if 'None' not in parsed_args.region:
286
282
  # NOTE (vishakha): Due to bug #1799153 and for any another
287
283
  # related case where GET resource API does not support the
288
284
  # filter by name, osc_lib.utils.find_resource() method cannot
@@ -402,7 +402,7 @@ class DeleteRole(command.Command):
402
402
 
403
403
  if errors > 0:
404
404
  total = len(parsed_args.roles)
405
- msg = _("%(errors)s of %(total)s roles failed " "to delete.") % {
405
+ msg = _("%(errors)s of %(total)s roles failed to delete.") % {
406
406
  'errors': errors,
407
407
  'total': total,
408
408
  }
@@ -428,28 +428,27 @@ class ListRole(command.Lister):
428
428
  domain = identity_client.find_domain(
429
429
  name_or_id=parsed_args.domain,
430
430
  )
431
- columns = ('ID', 'Name', 'Domain')
432
431
  data = identity_client.roles(domain_id=domain.id)
432
+ return (
433
+ ('ID', 'Name', 'Domain'),
434
+ (
435
+ utils.get_item_properties(s, ('id', 'name'))
436
+ + (domain.name,)
437
+ for s in data
438
+ ),
439
+ )
440
+
433
441
  else:
434
- columns = ('ID', 'Name')
435
442
  data = identity_client.roles()
436
-
437
- return (
438
- columns,
439
- (
440
- utils.get_item_properties(
441
- s,
442
- columns,
443
- formatters={'Domain': lambda _: domain.name},
444
- )
445
- for s in data
446
- ),
447
- )
443
+ return (
444
+ ('ID', 'Name'),
445
+ (utils.get_item_properties(s, ('id', 'name')) for s in data),
446
+ )
448
447
 
449
448
 
450
449
  class RemoveRole(command.Command):
451
450
  _description = _(
452
- "Removes a role assignment from system/domain/project : " "user/group"
451
+ "Removes a role assignment from system/domain/project : user/group"
453
452
  )
454
453
 
455
454
  def get_parser(self, prog_name):
@@ -135,9 +135,10 @@ class DeleteService(command.Command):
135
135
 
136
136
  if result > 0:
137
137
  total = len(parsed_args.service)
138
- msg = _(
139
- "%(result)s of %(total)s services failed " "to delete."
140
- ) % {'result': result, 'total': total}
138
+ msg = _("%(result)s of %(total)s services failed to delete.") % {
139
+ 'result': result,
140
+ 'total': total,
141
+ }
141
142
  raise exceptions.CommandError(msg)
142
143
 
143
144
 
@@ -157,12 +158,11 @@ class ListService(command.Lister):
157
158
  def take_action(self, parsed_args):
158
159
  identity_client = self.app.client_manager.sdk_connection.identity
159
160
 
161
+ columns: tuple[str, ...] = ('id', 'name', 'type')
162
+ column_headers: tuple[str, ...] = ('ID', 'Name', 'Type')
160
163
  if parsed_args.long:
161
- columns = ('id', 'name', 'type', 'description', 'is_enabled')
162
- column_headers = ('ID', 'Name', 'Type', 'Description', 'Enabled')
163
- else:
164
- columns = ('id', 'name', 'type')
165
- column_headers = ('ID', 'Name', 'Type')
164
+ columns += ('description', 'is_enabled')
165
+ column_headers += ('Description', 'Enabled')
166
166
 
167
167
  data = identity_client.services()
168
168
 
@@ -77,8 +77,7 @@ class CreateServiceProvider(command.ShowOne):
77
77
  metavar='<sp-url>',
78
78
  required=True,
79
79
  help=_(
80
- 'A service URL where SAML assertions are being sent '
81
- '(required)'
80
+ 'A service URL where SAML assertions are being sent (required)'
82
81
  ),
83
82
  )
84
83
 
@@ -155,8 +154,7 @@ class DeleteServiceProvider(command.Command):
155
154
  if result > 0:
156
155
  total = len(parsed_args.service_provider)
157
156
  msg = _(
158
- "%(result)s of %(total)s service providers failed"
159
- " to delete."
157
+ "%(result)s of %(total)s service providers failed to delete."
160
158
  ) % {'result': result, 'total': total}
161
159
  raise exceptions.CommandError(msg)
162
160
 
@@ -204,8 +202,7 @@ class SetServiceProvider(command.ShowOne):
204
202
  '--auth-url',
205
203
  metavar='<auth-url>',
206
204
  help=_(
207
- 'New Authentication URL of remote '
208
- 'federated service provider'
205
+ 'New Authentication URL of remote federated service provider'
209
206
  ),
210
207
  )
211
208