Skip to content

Commit d544a9b

Browse files
committed
moved policy command out of 'api' scope
1 parent 39aa5a3 commit d544a9b

File tree

4 files changed

+48
-48
lines changed

4 files changed

+48
-48
lines changed

src/azure-cli/azure/cli/command_modules/apim/_help.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
short-summary: Manage Azure API Management API's.
2929
"""
3030

31-
helps['apim api policy'] = """
31+
helps['apim policy'] = """
3232
type: group
3333
short-summary: Manage Azure API Management API Policies.
3434
"""
@@ -257,73 +257,73 @@
257257
az apim api export -g MyResourceGroup --service-name MyApim --api-id MyApi --export-format OpenApiJson --file-path path
258258
"""
259259

260-
helps['apim api policy set'] = """
260+
helps['apim policy set'] = """
261261
type: command
262262
short-summary: Create or update policy for the given Scope
263263
examples:
264264
- name: Create or update policy for API Operation
265265
text: |-
266-
az apim api policy set -g MyResourceGroup -n MyApim --api-id MyApi --operation-id MyOp --specification-path PathToXmlFile
266+
az apim policy set -g MyResourceGroup -n MyApim --api-id MyApi --operation-id MyOp --specification-path PathToXmlFile
267267
- name: Create or update policy for API
268268
text: |-
269-
az apim api policy set -g MyResourceGroup -n MyApim --api-id MyApi --specification-path PathToXmlFile
269+
az apim policy set -g MyResourceGroup -n MyApim --api-id MyApi --specification-path PathToXmlFile
270270
- name: Create or update global policy
271271
text: |-
272-
az apim api policy set -g MyResourceGroup -n MyApim --specification-path PathToXmlFile
272+
az apim policy set -g MyResourceGroup -n MyApim --specification-path PathToXmlFile
273273
"""
274274

275-
helps['apim api policy show'] = """
275+
helps['apim policy show'] = """
276276
type: command
277277
short-summary: Get policy for the given Scope
278278
examples:
279279
- name: Get policy for API Operation
280280
text: |-
281-
az apim api policy show -g MyResourceGroup -n MyApim --api-id MyApi --operation-id MyOp
281+
az apim policy show -g MyResourceGroup -n MyApim --api-id MyApi --operation-id MyOp
282282
- name: Get policy for API
283283
text: |-
284-
az apim api policy show -g MyResourceGroup -n MyApim --api-id MyApi
284+
az apim policy show -g MyResourceGroup -n MyApim --api-id MyApi
285285
- name: Get global policy
286286
text: |-
287-
az apim api policy show -g MyResourceGroup -n MyApim
287+
az apim policy show -g MyResourceGroup -n MyApim
288288
"""
289289

290-
helps['apim api policy delete'] = """
290+
helps['apim policy delete'] = """
291291
type: command
292292
short-summary: Delete policy for the given Scope
293293
examples:
294294
- name: Delete policy for API Operation
295295
text: |-
296-
az apim api policy delete -g MyResourceGroup -n MyApim --api-id MyApi --operation-id MyOp
296+
az apim policy delete -g MyResourceGroup -n MyApim --api-id MyApi --operation-id MyOp
297297
- name: Delete policy for API
298298
text: |-
299-
az apim api policy delete -g MyResourceGroup -n MyApim --api-id MyApi
299+
az apim policy delete -g MyResourceGroup -n MyApim --api-id MyApi
300300
- name: Delete global policy
301301
text: |-
302-
az apim api policy delete -g MyResourceGroup -n MyApim
302+
az apim policy delete -g MyResourceGroup -n MyApim
303303
"""
304304

305-
helps['apim api policy list'] = """
305+
helps['apim policy list'] = """
306306
type: command
307307
short-summary: List policies for the given Scope
308308
examples:
309309
- name: List policies for API Operation
310310
text: |-
311-
az apim api policy list -g MyResourceGroup -n MyApim --api-id MyApi --operation-id MyOp
311+
az apim policy list -g MyResourceGroup -n MyApim --api-id MyApi --operation-id MyOp
312312
- name: List policies for API
313313
text: |-
314-
az apim api policy list -g MyResourceGroup -n MyApim --api-id MyApi
314+
az apim policy list -g MyResourceGroup -n MyApim --api-id MyApi
315315
- name: List global policies
316316
text: |-
317-
az apim api policy list -g MyResourceGroup -n MyApim
317+
az apim policy list -g MyResourceGroup -n MyApim
318318
"""
319319

320-
helps['apim api policy wait'] = """
320+
helps['apim policy wait'] = """
321321
type: command
322322
short-summary: Place the CLI in a waiting state until a condition of an apim api is met.
323323
examples:
324324
- name: Place the CLI in a waiting state until a condition of a apim api is met.
325325
text: |
326-
az apim api policy wait --created --api-id MyApi --policy-id MyPolicy --name MyApim --resource-group MyResourceGroup
326+
az apim policy wait --created --api-id MyApi --policy-id MyPolicy --name MyApim --resource-group MyResourceGroup
327327
crafted: true
328328
"""
329329

src/azure-cli/azure/cli/command_modules/apim/_params.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,17 +314,17 @@ def load_arguments(self, _):
314314
c.argument('file_path', options_list=['--file-path', '-f'],
315315
help='File path specified to export the API.')
316316

317-
with self.argument_context('apim api policy') as c:
317+
with self.argument_context('apim policy') as c:
318318
c.argument('api_id', arg_type=api_id)
319319
c.argument('operation_id', help='Operation identifier within an API. Must be unique in the current API Management service instance.')
320320
c.argument('specification_path', help='Contents of the Policy as defined by the format.')
321321
c.argument('policy_format', help='Format of the policy content. Allowed formats: rawxml, rawxml-link, xml, xml-link')
322322
c.argument('policy_id', help='Policy identifier within an API. Must be unique in the current API context.')
323323

324-
with self.argument_context('apim api policy show') as c:
324+
with self.argument_context('apim policy show') as c:
325325
c.argument('file_path', help='Path to the file where the policy content will be saved. If not specified, the policy content will be printed to the standard output.')
326326

327-
with self.argument_context('apim api policy delete') as c:
327+
with self.argument_context('apim policy delete') as c:
328328
c.argument('if_match', help='ETag of the Entity.')
329329

330330
with self.argument_context('apim product api list') as c:

src/azure-cli/azure/cli/command_modules/apim/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def load_command_table(self, _):
112112
setter_name='begin_create_or_update', getter_name='get', supports_no_wait=True)
113113
g.wait_command('wait')
114114

115-
with self.command_group('apim api policy', api_policy_sdk) as g:
115+
with self.command_group('apim policy', api_policy_sdk) as g:
116116
g.custom_show_command('show', 'apim_api_policy_show')
117117
g.custom_command('set', 'apim_api_policy_set', supports_no_wait=True)
118118
g.custom_command('delete', 'apim_api_policy_delete', confirmation=True, supports_no_wait=True)

src/azure-cli/azure/cli/command_modules/apim/tests/latest/test_apim_scenario.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -639,70 +639,70 @@ def test_apim_policy_operations(self, resource_group, resource_group_location):
639639
self.kwargs['operation_name'] = operation_name
640640

641641
# Verify initial policy lists (global, API, and operation levels)
642-
initial_policy_global = self.cmd('apim api policy list -g {rg} -n {service_name}').get_output_in_json()
643-
initial_policy_api = self.cmd('apim api policy list -g {rg} -n {service_name} --api-id {api_id}').get_output_in_json()
644-
initial_policy_operation = self.cmd('apim api policy list -g {rg} -n {service_name} --api-id {api_id} --operation-id {operation_name}').get_output_in_json()
642+
initial_policy_global = self.cmd('apim policy list -g {rg} -n {service_name}').get_output_in_json()
643+
initial_policy_api = self.cmd('apim policy list -g {rg} -n {service_name} --api-id {api_id}').get_output_in_json()
644+
initial_policy_operation = self.cmd('apim policy list -g {rg} -n {service_name} --api-id {api_id} --operation-id {operation_name}').get_output_in_json()
645645

646646
# Set policies at different scopes
647-
self.cmd('apim api policy set -g {rg} -n {service_name} '
647+
self.cmd('apim policy set -g {rg} -n {service_name} '
648648
'--specification-path {policy_specification_path} '
649649
'--policy-format {policy_specification_format}')
650650

651-
self.cmd('apim api policy set -g {rg} -n {service_name} '
651+
self.cmd('apim policy set -g {rg} -n {service_name} '
652652
'--api-id {api_id} '
653653
'--specification-path {policy_specification_path} '
654654
'--policy-format {policy_specification_format}')
655655

656-
self.cmd('apim api policy set -g {rg} -n {service_name} '
656+
self.cmd('apim policy set -g {rg} -n {service_name} '
657657
'--api-id {api_id} '
658658
'--operation-id {operation_name} '
659659
'--specification-path {policy_specification_path} '
660660
'--policy-format {policy_specification_format}')
661661

662-
self.cmd('apim api policy wait -g "{rg}" -n "{service_name}" --api-id "{api_id}" --policy-id policy --exists', checks=[self.is_empty()])
662+
self.cmd('apim policy wait -g "{rg}" -n "{service_name}" --api-id "{api_id}" --policy-id policy --exists', checks=[self.is_empty()])
663663

664664
# Verify policies were updated
665-
current_policy_global = self.cmd('apim api policy list -g {rg} -n {service_name}').get_output_in_json()
666-
current_policy_api = self.cmd('apim api policy list -g {rg} -n {service_name} --api-id {api_id}').get_output_in_json()
667-
current_policy_operation = self.cmd('apim api policy list -g {rg} -n {service_name} --api-id {api_id} --operation-id {operation_name}').get_output_in_json()
665+
current_policy_global = self.cmd('apim policy list -g {rg} -n {service_name}').get_output_in_json()
666+
current_policy_api = self.cmd('apim policy list -g {rg} -n {service_name} --api-id {api_id}').get_output_in_json()
667+
current_policy_operation = self.cmd('apim policy list -g {rg} -n {service_name} --api-id {api_id} --operation-id {operation_name}').get_output_in_json()
668668

669669
# Ensure policies are different after update
670670
self.assertNotEqual(initial_policy_global['value'], current_policy_global['value'],
671671
"Global policy should have changed")
672672
self.assertNotEqual(initial_policy_api['value'], current_policy_api['value'],
673-
"API policy should have changed")
673+
"policy should have changed")
674674
self.assertNotEqual(initial_policy_operation['value'], current_policy_operation['value'],
675675
"Operation policy should have changed")
676676

677677
# Verify policy show commands
678-
self.cmd('apim api policy show -g {rg} -n {service_name}',
678+
self.cmd('apim policy show -g {rg} -n {service_name}',
679679
checks=[self.check('format', '{policy_specification_format}')])
680-
self.cmd('apim api policy show -g {rg} -n {service_name} --api-id {api_id}',
680+
self.cmd('apim policy show -g {rg} -n {service_name} --api-id {api_id}',
681681
checks=[self.check('format', '{policy_specification_format}')])
682-
self.cmd('apim api policy show -g {rg} -n {service_name} --api-id {api_id} --operation-id {operation_name}',
682+
self.cmd('apim policy show -g {rg} -n {service_name} --api-id {api_id} --operation-id {operation_name}',
683683
checks=[self.check('format', '{policy_specification_format}')])
684684

685685
# Get etag
686-
etag_global = self.cmd('apim api policy get-etag -g {rg} -n {service_name}').get_output_in_json()
687-
etag_api = self.cmd('apim api policy get-etag -g {rg} -n {service_name} --api-id {api_id}').get_output_in_json()
688-
etag_operation = self.cmd('apim api policy get-etag -g {rg} -n {service_name} --api-id {api_id} --operation-id {operation_name}').get_output_in_json()
686+
etag_global = self.cmd('apim policy get-etag -g {rg} -n {service_name}').get_output_in_json()
687+
etag_api = self.cmd('apim policy get-etag -g {rg} -n {service_name} --api-id {api_id}').get_output_in_json()
688+
etag_operation = self.cmd('apim policy get-etag -g {rg} -n {service_name} --api-id {api_id} --operation-id {operation_name}').get_output_in_json()
689689

690690
self.assertTrue(etag_global, "Global policy etag should not be empty")
691-
self.assertTrue(etag_api, "API policy etag should not be empty")
691+
self.assertTrue(etag_api, "policy etag should not be empty")
692692
self.assertTrue(etag_operation, "Operation policy etag should not be empty")
693693

694694
# Delete policies
695-
self.cmd('apim api policy delete -g {rg} -n {service_name} --yes')
696-
self.cmd('apim api policy delete -g {rg} -n {service_name} --api-id {api_id} --yes')
697-
self.cmd('apim api policy delete -g {rg} -n {service_name} --api-id {api_id} --operation-id {operation_name} --yes')
695+
self.cmd('apim policy delete -g {rg} -n {service_name} --yes')
696+
self.cmd('apim policy delete -g {rg} -n {service_name} --api-id {api_id} --yes')
697+
self.cmd('apim policy delete -g {rg} -n {service_name} --api-id {api_id} --operation-id {operation_name} --yes')
698698

699699
#wait
700-
self.cmd('apim api policy wait -g "{rg}" -n "{service_name}" --api-id "{api_id}" --policy-id policy --deleted', checks=[self.is_empty()])
700+
self.cmd('apim policy wait -g "{rg}" -n "{service_name}" --api-id "{api_id}" --policy-id policy --deleted', checks=[self.is_empty()])
701701

702702
# Verify policies are deleted
703-
final_policy_global = self.cmd('apim api policy list -g {rg} -n {service_name}').get_output_in_json()
704-
final_policy_api = self.cmd('apim api policy list -g {rg} -n {service_name} --api-id {api_id}').get_output_in_json()
705-
final_policy_operation = self.cmd('apim api policy list -g {rg} -n {service_name} --api-id {api_id} --operation-id {operation_name}').get_output_in_json()
703+
final_policy_global = self.cmd('apim policy list -g {rg} -n {service_name}').get_output_in_json()
704+
final_policy_api = self.cmd('apim policy list -g {rg} -n {service_name} --api-id {api_id}').get_output_in_json()
705+
final_policy_operation = self.cmd('apim policy list -g {rg} -n {service_name} --api-id {api_id} --operation-id {operation_name}').get_output_in_json()
706706

707707
self.assertEqual(final_policy_global.get('count', 0), 0, "Global policy should be deleted")
708708
self.assertEqual(final_policy_api.get('count', 0), 0, "API policy should be deleted")

0 commit comments

Comments
 (0)