Skip to content

Commit e1a6afe

Browse files
authored
[Cognitive Services] Bump cognitiveservices to 2021-10-01 (#20551)
* Cognitive Services CLI upgrade to API 2021-10-01 * undo change in __init__
1 parent ba6065c commit e1a6afe

33 files changed

+3157
-1594
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,17 @@ def cf_deleted_accounts(cli_ctx, *_):
1818
return get_cognitiveservices_management_client(cli_ctx).deleted_accounts
1919

2020

21+
def cf_deployments(cli_ctx, *_):
22+
return get_cognitiveservices_management_client(cli_ctx).deployments
23+
24+
25+
def cf_commitment_tiers(cli_ctx, *_):
26+
return get_cognitiveservices_management_client(cli_ctx).commitment_tiers
27+
28+
29+
def cf_commitment_plans(cli_ctx, *_):
30+
return get_cognitiveservices_management_client(cli_ctx).commitment_plans
31+
32+
2133
def cf_resource_skus(cli_ctx, *_):
2234
return get_cognitiveservices_management_client(cli_ctx).resource_skus

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

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,99 @@
240240
- name: Purge a soft-deleted Azure Cognitive Services account.
241241
text: az cognitiveservices account purge --location eastus --resource-group cognitive-services-resource-group --name cognitive-services-account-name
242242
"""
243+
244+
helps['cognitiveservices account deployment'] = """
245+
type: group
246+
short-summary: Manage deployments for Azure Cognitive Services accounts.
247+
"""
248+
249+
helps['cognitiveservices account deployment create'] = """
250+
type: command
251+
short-summary: Create a deployment for Azure Cognitive Services account.
252+
long-summary: This article lists the Azure CLI commands for Azure Cognitive Services account and subscription management only. Refer to the documentation at https://docs.microsoft.com/azure/cognitive-services/ for individual services to learn how to use the APIs and supported SDKs.
253+
examples:
254+
- name: Create a deployment for Azure Cognitive Services account.
255+
text: az cognitiveservices account deployment create -g yuanyang-test-sdk -n yytest-oai --deployment-name dpy --model-name ada --model-version "1" --model-format OpenAI --scale-settings-capacity 1 --scale-settings-scale-type "Manual"
256+
"""
257+
258+
helps['cognitiveservices account deployment delete'] = """
259+
type: command
260+
short-summary: Delete a deployment from Azure Cognitive Services account.
261+
long-summary: This article lists the Azure CLI commands for Azure Cognitive Services account and subscription management only. Refer to the documentation at https://docs.microsoft.com/azure/cognitive-services/ for individual services to learn how to use the APIs and supported SDKs.
262+
examples:
263+
- name: Delete a deployment from Azure Cognitive Services account.
264+
text: az cognitiveservices account deployment delete -g yuanyang-test-sdk -n yytest-oai --deployment-name dpy
265+
"""
266+
267+
helps['cognitiveservices account deployment show'] = """
268+
type: command
269+
short-summary: Show a deployment for Azure Cognitive Services account.
270+
long-summary: This article lists the Azure CLI commands for Azure Cognitive Services account and subscription management only. Refer to the documentation at https://docs.microsoft.com/azure/cognitive-services/ for individual services to learn how to use the APIs and supported SDKs.
271+
examples:
272+
- name: Show a deployment for Azure Cognitive Services account.
273+
text: az cognitiveservices account deployment show -g yuanyang-test-sdk -n yytest-oai --deployment-name dpy
274+
"""
275+
276+
helps['cognitiveservices account deployment list'] = """
277+
type: command
278+
short-summary: Show all deployments for Azure Cognitive Services account.
279+
long-summary: This article lists the Azure CLI commands for Azure Cognitive Services account and subscription management only. Refer to the documentation at https://docs.microsoft.com/azure/cognitive-services/ for individual services to learn how to use the APIs and supported SDKs.
280+
examples:
281+
- name: Show all deployments for Azure Cognitive Services account.
282+
text: az cognitiveservices account deployment list -g yuanyang-test-sdk -n yytest-oai
283+
"""
284+
285+
helps['cognitiveservices commitment-tier'] = """
286+
type: group
287+
short-summary: Manage commitment tiers for Azure Cognitive Services.
288+
"""
289+
290+
helps['cognitiveservices commitment-tier list'] = """
291+
type: command
292+
short-summary: Show all commitment tiers for Azure Cognitive Services.
293+
long-summary: This article lists the Azure CLI commands for Azure Cognitive Services account and subscription management only. Refer to the documentation at https://docs.microsoft.com/azure/cognitive-services/ for individual services to learn how to use the APIs and supported SDKs.
294+
examples:
295+
- name: Show all commitment tiers for Azure Cognitive Services.
296+
text: az cognitiveservices commitment-tier list -l centraluseuap
297+
"""
298+
299+
helps['cognitiveservices account commitment-plan'] = """
300+
type: group
301+
short-summary: Manage commitment plans for Azure Cognitive Services accounts.
302+
"""
303+
304+
helps['cognitiveservices account commitment-plan create'] = """
305+
type: command
306+
short-summary: Create a commitment plan for Azure Cognitive Services account.
307+
long-summary: This article lists the Azure CLI commands for Azure Cognitive Services account and subscription management only. Refer to the documentation at https://docs.microsoft.com/azure/cognitive-services/ for individual services to learn how to use the APIs and supported SDKs.
308+
examples:
309+
- name: Create a commitment plan for Azure Cognitive Services account.
310+
text: az cognitiveservices account commitment-plan create -g yuanyang-test-sdk -n yytest-ta --commitment-plan-name "plan" --hosting-model "Web" --plan-type "TA" --auto-renew false --current-tier "T1" --next-tier "T2"
311+
"""
312+
313+
helps['cognitiveservices account commitment-plan delete'] = """
314+
type: command
315+
short-summary: Delete a commitment plan from Azure Cognitive Services account.
316+
long-summary: This article lists the Azure CLI commands for Azure Cognitive Services account and subscription management only. Refer to the documentation at https://docs.microsoft.com/azure/cognitive-services/ for individual services to learn how to use the APIs and supported SDKs.
317+
examples:
318+
- name: Delete a commitment plan from Azure Cognitive Services account.
319+
text: az cognitiveservices account commitment-plan delete -g yuanyang-test-sdk -n yytest-ta --commitment-plan-name "plan"
320+
"""
321+
322+
helps['cognitiveservices account commitment-plan show'] = """
323+
type: command
324+
short-summary: Show a commitment plan from Azure Cognitive Services account.
325+
long-summary: This article lists the Azure CLI commands for Azure Cognitive Services account and subscription management only. Refer to the documentation at https://docs.microsoft.com/azure/cognitive-services/ for individual services to learn how to use the APIs and supported SDKs.
326+
examples:
327+
- name: Show a commitment plan from Azure Cognitive Services account.
328+
text: az cognitiveservices account commitment-plan show -g yuanyang-test-sdk -n yytest-ta --commitment-plan-name "plan"
329+
"""
330+
331+
helps['cognitiveservices account commitment-plan list'] = """
332+
type: command
333+
short-summary: Show all commitment plans from Azure Cognitive Services account.
334+
long-summary: This article lists the Azure CLI commands for Azure Cognitive Services account and subscription management only. Refer to the documentation at https://docs.microsoft.com/azure/cognitive-services/ for individual services to learn how to use the APIs and supported SDKs.
335+
examples:
336+
- name: Show all commitment plans from Azure Cognitive Services account.
337+
text: az cognitiveservices account commitment-plan list -g yuanyang-test-sdk -n yytest-ta
338+
"""

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

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from azure.cli.core.commands.parameters import (
1111
tags_type,
1212
get_enum_type,
13+
get_three_state_flag,
1314
resource_group_name_type,
1415
get_resource_name_completion_list,
1516
get_location_type)
@@ -20,7 +21,7 @@
2021

2122
from azure.cli.command_modules.cognitiveservices._client_factory import cf_resource_skus
2223

23-
from azure.mgmt.cognitiveservices.models import KeyName
24+
from azure.mgmt.cognitiveservices.models import KeyName, DeploymentScaleType, HostingModel
2425

2526
logger = get_logger(__name__)
2627
name_arg_type = CLIArgumentType(options_list=['--name', '-n'], metavar='NAME')
@@ -164,3 +165,36 @@ def load_arguments(self, _):
164165
c.argument('ip_address', help='IPv4 address or CIDR range.')
165166
c.argument('subnet', help='Name or ID of subnet. If name is supplied, `--vnet-name` must be supplied.')
166167
c.argument('vnet_name', help='Name of a virtual network.', validator=_validate_subnet)
168+
169+
with self.argument_context('cognitiveservices account deployment') as c:
170+
c.argument('deployment_name', help='Cognitive Services account deployment name')
171+
172+
with self.argument_context('cognitiveservices account deployment', arg_group='DeploymentModel') as c:
173+
c.argument('model_name', help='Cognitive Services account deployment model name.')
174+
c.argument('model_format', help='Cognitive Services account deployment model format.')
175+
c.argument('model_version', help='Cognitive Services account deployment model version.')
176+
177+
with self.argument_context('cognitiveservices account deployment', arg_group='DeploymentScaleSettings') as c:
178+
c.argument(
179+
'scale_settings_scale_type', get_enum_type(DeploymentScaleType),
180+
options_list=['--scale-type', '--scale-settings-scale-type'],
181+
help='Cognitive Services account deployment scale settings scale type.')
182+
c.argument(
183+
'scale_settings_capacity', options_list=['--scale-capacity', '--scale-settings-capacity'],
184+
help='Cognitive Services account deployment scale settings capacity.')
185+
186+
with self.argument_context('cognitiveservices account commitment-plan') as c:
187+
c.argument('commitment_plan_name', help='Cognitive Services account commitment plan name')
188+
c.argument('plan_type', help='Cognitive Services account commitment plan type')
189+
c.argument('hosting_model', get_enum_type(HostingModel), help='Cognitive Services account hosting model')
190+
c.argument(
191+
'auto_renew', arg_type=get_three_state_flag(),
192+
help='A boolean indicating whether to apply auto renew.')
193+
194+
with self.argument_context('cognitiveservices account commitment-plan', arg_group='Current CommitmentPeriod') as c:
195+
c.argument('current_count', help='Cognitive Services account commitment plan current commitment period count.')
196+
c.argument('current_tier', help='Cognitive Services account commitment plan current commitment period tier.')
197+
198+
with self.argument_context('cognitiveservices account commitment-plan', arg_group='Next CommitmentPeriod') as c:
199+
c.argument('next_count', help='Cognitive Services account commitment plan next commitment period count.')
200+
c.argument('next_tier', help='Cognitive Services account commitment plan next commitment period tier.')

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

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,31 @@
55

66
from azure.cli.core.commands import CliCommandType
77
from azure.cli.command_modules.cognitiveservices._client_factory import cf_accounts, cf_resource_skus,\
8-
cf_deleted_accounts
8+
cf_deleted_accounts, cf_deployments, cf_commitment_plans, cf_commitment_tiers
99

1010

1111
def load_command_table(self, _):
12-
mgmt_type = CliCommandType(
12+
accounts_type = CliCommandType(
1313
operations_tmpl='azure.mgmt.cognitiveservices.operations#AccountsOperations.{}',
1414
client_factory=cf_accounts
1515
)
1616

17-
with self.command_group('cognitiveservices account', mgmt_type) as g:
17+
deployments_type = CliCommandType(
18+
operations_tmpl='azure.mgmt.cognitiveservices.operations#DeploymentsOperations.{}',
19+
client_factory=cf_deployments
20+
)
21+
22+
commitment_plans_type = CliCommandType(
23+
operations_tmpl='azure.mgmt.cognitiveservices.operations#CommitmentPlansOperations.{}',
24+
client_factory=cf_commitment_plans
25+
)
26+
27+
commitment_tiers_type = CliCommandType(
28+
operations_tmpl='azure.mgmt.cognitiveservices.operations#CommitmentTiersOperations.{}',
29+
client_factory=cf_commitment_tiers
30+
)
31+
32+
with self.command_group('cognitiveservices account', accounts_type, client_factory=cf_accounts) as g:
1833
g.custom_command('create', 'create')
1934
g.command('delete', 'begin_delete')
2035
g.show_command('show', 'get')
@@ -34,21 +49,40 @@ def load_command_table(self, _):
3449
g.custom_command('list-usage', 'list_usages')
3550
g.custom_command('list-kinds', 'list_kinds', client_factory=cf_resource_skus)
3651

37-
with self.command_group('cognitiveservices account keys', mgmt_type) as g:
52+
with self.command_group('cognitiveservices account keys', accounts_type) as g:
3853
g.command('regenerate', 'regenerate_key')
3954
g.command('list', 'list_keys')
4055

4156
# deprecating this
42-
with self.command_group('cognitiveservices') as g:
57+
with self.command_group('cognitiveservices', client_factory=cf_accounts) as g:
4358
g.custom_command('list', 'list_resources',
4459
deprecate_info=g.deprecate(redirect='az cognitiveservices account list', hide=True))
4560

46-
with self.command_group('cognitiveservices account network-rule', mgmt_type, client_factory=cf_accounts) as g:
61+
with self.command_group('cognitiveservices account network-rule', accounts_type, client_factory=cf_accounts) as g:
4762
g.custom_command('add', 'add_network_rule')
4863
g.custom_command('list', 'list_network_rules')
4964
g.custom_command('remove', 'remove_network_rule')
5065

51-
with self.command_group('cognitiveservices account identity', mgmt_type, client_factory=cf_accounts) as g:
66+
with self.command_group('cognitiveservices account identity', accounts_type, client_factory=cf_accounts) as g:
5267
g.custom_command('assign', 'identity_assign')
5368
g.custom_command('remove', 'identity_remove')
5469
g.custom_show_command('show', 'identity_show')
70+
71+
with self.command_group(
72+
'cognitiveservices account deployment', deployments_type,
73+
client_factory=cf_deployments) as g:
74+
g.custom_command('create', 'deployment_begin_create_or_update')
75+
g.command('delete', 'begin_delete')
76+
g.show_command('show', 'get')
77+
g.command('list', 'list')
78+
79+
with self.command_group(
80+
'cognitiveservices account commitment-plan', commitment_plans_type,
81+
client_factory=cf_commitment_plans) as g:
82+
g.custom_command('create', 'commitment_plan_create_or_update')
83+
g.command('delete', 'begin_delete')
84+
g.show_command('show', 'get')
85+
g.command('list', 'list')
86+
87+
with self.command_group('cognitiveservices commitment-tier', commitment_tiers_type) as g:
88+
g.command('list', 'list')

0 commit comments

Comments
 (0)