Skip to content

Commit 474caf9

Browse files
fix: fixed PR recommendations
1 parent ec135b1 commit 474caf9

File tree

9 files changed

+2650
-1336
lines changed

9 files changed

+2650
-1336
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@ def cf_graphqlapiresolver(cli_ctx, *_):
5757
def cf_graphqlapiresolverpolicy(cli_ctx, *_):
5858
return cf_apim(cli_ctx).graph_ql_api_resolver_policy
5959

60+
6061
def cf_backend(cli_ctx, *_):
61-
return cf_apim(cli_ctx).backend
62+
return cf_apim(cli_ctx).backend

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,11 +812,8 @@
812812
short-summary: unique name of the Backend to be updated
813813
long-summary: |
814814
Must be unique in the current API Management service instance.
815-
- name: --if-match
816-
type: string
817-
short-summary: ETag of the Backend entity. ETag should match the current entity state from the service to perform an update. Use "*" for unconditional update.
818815
examples:
819816
- name: Update a Backend.
820817
text: |-
821-
az apim backend update --service-name MyApim -g MyResourceGroup --backend-id MyBackendId --if-match "*"
822-
"""
818+
az apim backend update --service-name MyApim -g MyResourceGroup --backend-id MyBackendId --url https://mynewbackend.com
819+
"""

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

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
API_TYPES = ApiType
2323
BACKEND_PROTOCOLS = BackendProtocol
2424

25+
2526
class ImportFormat(Enum):
2627
Wadl = "Wadl"
2728
Swagger = "Swagger"
@@ -52,7 +53,7 @@ def load_arguments(self, _):
5253
schema_id = CLIArgumentType(arg_group='Schema',
5354
help='Schema identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.')
5455
backend_id = CLIArgumentType(arg_group='Backend',
55-
help='Backend identifier. Must be unique in the current API Management service instance. Non-current revision has ;rev=n as a suffix where n is the revision number.')
56+
help='Backend identifier. Must be unique in the current API Management service instance.')
5657

5758
from azure.cli.core.commands.parameters import tags_type
5859
from azure.cli.core.commands.validators import get_default_location_from_resource_group
@@ -505,14 +506,34 @@ def load_arguments(self, _):
505506
c.argument('resolver_id', help='Resolver identifier within a GraphQL API. Must be unique in the current API Management service instance.')
506507
c.argument('if_match', help='ETag of the Entity.')
507508

508-
with self.argument_context('apim backend') as c:
509+
with self.argument_context('apim backend create') as c:
510+
c.argument('service_name', options_list=['--service-name', '-n'],
511+
help='The name of the API Management service instance.')
512+
c.argument('backend_id', arg_type=backend_id, help='Identifier of the Backend.')
513+
c.argument('url', help='Required. Backend service URL.')
514+
c.argument('protocol', arg_type=get_enum_type(BACKEND_PROTOCOLS),
515+
help='Protocol used to communicate with the backend service. Possible values include: `http`, `soap`.')
516+
c.argument('description', help='Description of the Backend. May include HTML formatting tags.')
517+
518+
with self.argument_context('apim backend update') as c:
509519
c.argument('service_name', options_list=['--service-name', '-n'],
510520
help='The name of the API Management service instance.')
511521
c.argument('backend_id', arg_type=backend_id, help='Identifier of the Backend.')
512522
c.argument('url', help='Required. Backend service URL.')
513523
c.argument('protocol', arg_type=get_enum_type(BACKEND_PROTOCOLS),
514524
help='Protocol used to communicate with the backend service. Possible values include: `http`, `soap`.')
515-
c.argument('title', help='Backend title.')
516525
c.argument('description', help='Description of the Backend. May include HTML formatting tags.')
517-
c.argument('resource_id', help='Resource ID of the backend service.')
518-
c.argument('if_match', help='ETag of the Entity.')
526+
527+
with self.argument_context('apim backend delete') as c:
528+
c.argument('service_name', options_list=['--service-name', '-n'],
529+
help='The name of the API Management service instance.')
530+
c.argument('backend_id', arg_type=backend_id, help='Identifier of the Backend.')
531+
532+
with self.argument_context('apim backend show') as c:
533+
c.argument('service_name', options_list=['--service-name', '-n'],
534+
help='The name of the API Management service instance.')
535+
c.argument('backend_id', arg_type=backend_id, help='Identifier of the Backend.')
536+
537+
with self.argument_context('apim backend list') as c:
538+
c.argument('service_name', options_list=['--service-name', '-n'],
539+
help='The name of the API Management service instance.')

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,5 @@ def load_command_table(self, _):
189189
g.custom_show_command('show', 'apim_backend_show')
190190
g.custom_command('list', 'apim_backend_list')
191191
g.custom_command('delete', 'apim_backend_delete', confirmation=True, supports_no_wait=True)
192-
g.generic_update_command('update', custom_func_name='apim_backend_update',
193-
setter_name='update', getter_name='get', supports_no_wait=True)
194-
g.wait_command('wait')
192+
g.generic_update_command('update', custom_func_name='apim_backend_update', supports_no_wait=True)
193+
g.wait_command('wait')

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

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,17 +1167,15 @@ def apim_graphql_resolver_policy_delete(
11671167
policy_id="policy",
11681168
if_match="*" if if_match is None else if_match)
11691169

1170+
11701171
def apim_backend_create(
11711172
client, resource_group_name, service_name, backend_id, url, protocol, description=None,
1172-
title=None, resource_id=None, properties=None, if_match=None, no_wait=False):
1173+
no_wait=False, if_match=None):
11731174

11741175
parameters = BackendContract(
11751176
url=url,
11761177
protocol=protocol,
1177-
description=description,
1178-
title=title,
1179-
resource_id=resource_id,
1180-
properties=properties
1178+
description=description
11811179
)
11821180

11831181
return sdk_no_wait(no_wait, client.backend.create_or_update,
@@ -1187,15 +1185,17 @@ def apim_backend_create(
11871185
parameters=parameters,
11881186
if_match="*" if if_match is None else if_match)
11891187

1188+
11901189
def apim_backend_delete(
11911190
client, resource_group_name, service_name, backend_id, if_match=None, no_wait=False):
11921191

11931192
return sdk_no_wait(no_wait,
1194-
client.backend.delete,
1195-
resource_group_name=resource_group_name,
1196-
service_name=service_name,
1197-
backend_id=backend_id,
1198-
if_match="*" if if_match is None else if_match)
1193+
client.backend.delete,
1194+
resource_group_name=resource_group_name,
1195+
service_name=service_name,
1196+
backend_id=backend_id,
1197+
if_match="*" if if_match is None else if_match)
1198+
11991199

12001200
def apim_backend_show(client, resource_group_name, service_name, backend_id):
12011201

@@ -1204,15 +1204,16 @@ def apim_backend_show(client, resource_group_name, service_name, backend_id):
12041204
service_name=service_name,
12051205
backend_id=backend_id)
12061206

1207+
12071208
def apim_backend_list(client, resource_group_name, service_name):
12081209

12091210
return client.backend.list_by_service(
12101211
resource_group_name=resource_group_name,
12111212
service_name=service_name)
12121213

1214+
12131215
def apim_backend_update(
1214-
instance, url=None, protocol=None, description=None,
1215-
title=None, resource_id=None, properties=None):
1216+
instance, url=None, protocol=None, description=None):
12161217

12171218
if url is not None:
12181219
instance.url = url
@@ -1223,13 +1224,4 @@ def apim_backend_update(
12231224
if description is not None:
12241225
instance.description = description
12251226

1226-
if title is not None:
1227-
instance.title = title
1228-
1229-
if resource_id is not None:
1230-
instance.resource_id = resource_id
1231-
1232-
if properties is not None:
1233-
instance.properties = properties
1234-
1235-
return instance
1227+
return instance

0 commit comments

Comments
 (0)