Skip to content

Commit ca37f6a

Browse files
chore: fixed PR recommendations
1 parent 72e9fbe commit ca37f6a

File tree

9 files changed

+2838
-1232
lines changed

9 files changed

+2838
-1232
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: 28 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,36 @@ 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:
509510
c.argument('service_name', options_list=['--service-name', '-n'],
510511
help='The name of the API Management service instance.')
511512
c.argument('backend_id', arg_type=backend_id, help='Identifier of the Backend.')
512513
c.argument('url', help='Required. Backend service URL.')
513514
c.argument('protocol', arg_type=get_enum_type(BACKEND_PROTOCOLS),
514515
help='Protocol used to communicate with the backend service. Possible values include: `http`, `soap`.')
515-
c.argument('title', help='Backend title.')
516516
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.')
517+
c.argument('if_match', help='ETag of the Entity.')
518+
519+
with self.argument_context('apim backend update') as c:
520+
c.argument('service_name', options_list=['--service-name', '-n'],
521+
help='The name of the API Management service instance.')
522+
c.argument('backend_id', arg_type=backend_id, help='Identifier of the Backend.')
523+
c.argument('url', help='Required. Backend service URL.')
524+
c.argument('protocol', arg_type=get_enum_type(BACKEND_PROTOCOLS),
525+
help='Protocol used to communicate with the backend service. Possible values include: `http`, `soap`.')
526+
c.argument('description', help='Description of the Backend. May include HTML formatting tags.')
527+
528+
with self.argument_context('apim backend delete') as c:
529+
c.argument('service_name', options_list=['--service-name', '-n'],
530+
help='The name of the API Management service instance.')
531+
c.argument('backend_id', arg_type=backend_id, help='Identifier of the Backend.')
532+
c.argument('if_match', help='ETag of the Entity.')
533+
534+
with self.argument_context('apim backend show') as c:
535+
c.argument('service_name', options_list=['--service-name', '-n'],
536+
help='The name of the API Management service instance.')
537+
c.argument('backend_id', arg_type=backend_id, help='Identifier of the Backend.')
538+
539+
with self.argument_context('apim backend list') as c:
540+
c.argument('service_name', options_list=['--service-name', '-n'],
541+
help='The name of the API Management service instance.')

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,8 @@ def load_command_table(self, _):
185185
g.custom_command('list', 'apim_graphql_resolver_policy_list')
186186

187187
with self.command_group('apim backend', backend_sdk) as g:
188-
g.custom_command('create', 'apim_backend_create', supports_no_wait=True)
188+
g.custom_command('create', 'apim_backend_create')
189189
g.custom_show_command('show', 'apim_backend_show')
190190
g.custom_command('list', 'apim_backend_list')
191-
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')
191+
g.custom_command('delete', 'apim_backend_delete', confirmation=True)
192+
g.generic_update_command('update', custom_func_name='apim_backend_update')

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)