Skip to content

Commit 69a8957

Browse files
author
Scott Clark
committed
#32209 az apim export to allow for specified file name
1 parent 8d0c503 commit 69a8957

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@
249249
examples:
250250
- name: Export an API Management API to a file or returns a response containing a link of the export.
251251
text: |-
252-
az apim api export -g MyResourceGroup --service-name MyApim --api-id MyApi --export-format OpenApiJson --file-path path
252+
az apim api export -g MyResourceGroup --service-name MyApim --api-id MyApi --export-format OpenApiJson --file-path path --file-name name
253253
"""
254254

255255
helps['apim product api list'] = """

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ def load_arguments(self, _):
313313
help='Specify the format of the exporting API.')
314314
c.argument('file_path', options_list=['--file-path', '-f'],
315315
help='File path specified to export the API.')
316+
c.argument('file_name', options_list=['--file-name'],
317+
help='File name specified to export the API.')
316318

317319
with self.argument_context('apim product api list') as c:
318320
c.argument('service_name', options_list=['--service-name', '-n'],

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ def apim_api_import(
516516
parameters=parameters)
517517

518518

519-
def apim_api_export(client, resource_group_name, service_name, api_id, export_format, file_path=None):
519+
def apim_api_export(client, resource_group_name, service_name, api_id, export_format, file_path=None, file_name=None,):
520520
"""Gets the details of the API specified by its identifier in the format specified """
521521

522522
import json
@@ -572,7 +572,8 @@ def apim_api_export(client, resource_group_name, service_name, api_id, export_fo
572572

573573
# Remove '-link' from the mappedFormat and create the file name with full path
574574
exportType = mappedFormat.replace('-link', '')
575-
file_name = f"{api_id}_{exportType}{file_extension}"
575+
if file_name is None:
576+
file_name = f"{api_id}_{exportType}{file_extension}"
576577
full_path = os.path.join(file_path, file_name)
577578

578579
# Get the results from the link where the API Export Results are stored

0 commit comments

Comments
 (0)