Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,17 @@ def cf_deleted_accounts(cli_ctx, *_):
return get_cognitiveservices_management_client(cli_ctx).deleted_accounts


def cf_deployments(cli_ctx, *_):
return get_cognitiveservices_management_client(cli_ctx).deployments


def cf_commitment_tiers(cli_ctx, *_):
return get_cognitiveservices_management_client(cli_ctx).commitment_tiers


def cf_commitment_plans(cli_ctx, *_):
return get_cognitiveservices_management_client(cli_ctx).commitment_plans


def cf_resource_skus(cli_ctx, *_):
return get_cognitiveservices_management_client(cli_ctx).resource_skus
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,99 @@
- name: Purge a soft-deleted Azure Cognitive Services account.
text: az cognitiveservices account purge --location eastus --resource-group cognitive-services-resource-group --name cognitive-services-account-name
"""

helps['cognitiveservices account deployment'] = """
type: group
short-summary: Manage deployments for Azure Cognitive Services accounts.
"""

helps['cognitiveservices account deployment create'] = """
type: command
short-summary: Create a deployment for Azure Cognitive Services account.
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.
examples:
- name: Create a deployment for Azure Cognitive Services account.
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"
"""

helps['cognitiveservices account deployment delete'] = """
type: command
short-summary: Delete a deployment from Azure Cognitive Services account.
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.
examples:
- name: Delete a deployment from Azure Cognitive Services account.
text: az cognitiveservices account deployment delete -g yuanyang-test-sdk -n yytest-oai --deployment-name dpy
"""

helps['cognitiveservices account deployment show'] = """
type: command
short-summary: Show a deployment for Azure Cognitive Services account.
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.
examples:
- name: Show a deployment for Azure Cognitive Services account.
text: az cognitiveservices account deployment show -g yuanyang-test-sdk -n yytest-oai --deployment-name dpy
"""

helps['cognitiveservices account deployment list'] = """
type: command
short-summary: Show all deployments for Azure Cognitive Services account.
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.
examples:
- name: Show all deployments for Azure Cognitive Services account.
text: az cognitiveservices account deployment list -g yuanyang-test-sdk -n yytest-oai
"""

helps['cognitiveservices commitment-tier'] = """
type: group
short-summary: Manage commitment tiers for Azure Cognitive Services.
"""

helps['cognitiveservices commitment-tier list'] = """
type: command
short-summary: Show all commitment tiers for Azure Cognitive Services.
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.
examples:
- name: Show all commitment tiers for Azure Cognitive Services.
text: az cognitiveservices commitment-tier list -l centraluseuap
"""

helps['cognitiveservices account commitment-plan'] = """
type: group
short-summary: Manage commitment plans for Azure Cognitive Services accounts.
"""

helps['cognitiveservices account commitment-plan create'] = """
type: command
short-summary: Create a commitment plan for Azure Cognitive Services account.
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.
examples:
- name: Create a commitment plan for Azure Cognitive Services account.
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"
"""

helps['cognitiveservices account commitment-plan delete'] = """
type: command
short-summary: Delete a commitment plan from Azure Cognitive Services account.
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.
examples:
- name: Delete a commitment plan from Azure Cognitive Services account.
text: az cognitiveservices account commitment-plan delete -g yuanyang-test-sdk -n yytest-ta --commitment-plan-name "plan"
"""

helps['cognitiveservices account commitment-plan show'] = """
type: command
short-summary: Show a commitment plan from Azure Cognitive Services account.
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.
examples:
- name: Show a commitment plan from Azure Cognitive Services account.
text: az cognitiveservices account commitment-plan show -g yuanyang-test-sdk -n yytest-ta --commitment-plan-name "plan"
"""

helps['cognitiveservices account commitment-plan list'] = """
type: command
short-summary: Show all commitment plans from Azure Cognitive Services account.
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.
examples:
- name: Show all commitment plans from Azure Cognitive Services account.
text: az cognitiveservices account commitment-plan list -g yuanyang-test-sdk -n yytest-ta
"""
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from azure.cli.core.commands.parameters import (
tags_type,
get_enum_type,
get_three_state_flag,
resource_group_name_type,
get_resource_name_completion_list,
get_location_type)
Expand All @@ -20,7 +21,7 @@

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

from azure.mgmt.cognitiveservices.models import KeyName
from azure.mgmt.cognitiveservices.models import KeyName, DeploymentScaleType, HostingModel

logger = get_logger(__name__)
name_arg_type = CLIArgumentType(options_list=['--name', '-n'], metavar='NAME')
Expand Down Expand Up @@ -164,3 +165,36 @@ def load_arguments(self, _):
c.argument('ip_address', help='IPv4 address or CIDR range.')
c.argument('subnet', help='Name or ID of subnet. If name is supplied, `--vnet-name` must be supplied.')
c.argument('vnet_name', help='Name of a virtual network.', validator=_validate_subnet)

with self.argument_context('cognitiveservices account deployment') as c:
c.argument('deployment_name', help='Cognitive Services account deployment name')

with self.argument_context('cognitiveservices account deployment', arg_group='DeploymentModel') as c:
c.argument('model_name', help='Cognitive Services account deployment model name.')
c.argument('model_format', help='Cognitive Services account deployment model format.')
c.argument('model_version', help='Cognitive Services account deployment model version.')

with self.argument_context('cognitiveservices account deployment', arg_group='DeploymentScaleSettings') as c:
c.argument(
'scale_settings_scale_type', get_enum_type(DeploymentScaleType),
options_list=['--scale-type', '--scale-settings-scale-type'],
help='Cognitive Services account deployment scale settings scale type.')
c.argument(
'scale_settings_capacity', options_list=['--scale-capacity', '--scale-settings-capacity'],
help='Cognitive Services account deployment scale settings capacity.')

with self.argument_context('cognitiveservices account commitment-plan') as c:
c.argument('commitment_plan_name', help='Cognitive Services account commitment plan name')
c.argument('plan_type', help='Cognitive Services account commitment plan type')
c.argument('hosting_model', get_enum_type(HostingModel), help='Cognitive Services account hosting model')
c.argument(
'auto_renew', arg_type=get_three_state_flag(),
help='A boolean indicating whether to apply auto renew.')

with self.argument_context('cognitiveservices account commitment-plan', arg_group='Current CommitmentPeriod') as c:
c.argument('current_count', help='Cognitive Services account commitment plan current commitment period count.')
c.argument('current_tier', help='Cognitive Services account commitment plan current commitment period tier.')

with self.argument_context('cognitiveservices account commitment-plan', arg_group='Next CommitmentPeriod') as c:
c.argument('next_count', help='Cognitive Services account commitment plan next commitment period count.')
c.argument('next_tier', help='Cognitive Services account commitment plan next commitment period tier.')
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,31 @@

from azure.cli.core.commands import CliCommandType
from azure.cli.command_modules.cognitiveservices._client_factory import cf_accounts, cf_resource_skus,\
cf_deleted_accounts
cf_deleted_accounts, cf_deployments, cf_commitment_plans, cf_commitment_tiers


def load_command_table(self, _):
mgmt_type = CliCommandType(
accounts_type = CliCommandType(
operations_tmpl='azure.mgmt.cognitiveservices.operations#AccountsOperations.{}',
client_factory=cf_accounts
)

with self.command_group('cognitiveservices account', mgmt_type) as g:
deployments_type = CliCommandType(
operations_tmpl='azure.mgmt.cognitiveservices.operations#DeploymentsOperations.{}',
client_factory=cf_deployments
)

commitment_plans_type = CliCommandType(
operations_tmpl='azure.mgmt.cognitiveservices.operations#CommitmentPlansOperations.{}',
client_factory=cf_commitment_plans
)

commitment_tiers_type = CliCommandType(
operations_tmpl='azure.mgmt.cognitiveservices.operations#CommitmentTiersOperations.{}',
client_factory=cf_commitment_tiers
)

with self.command_group('cognitiveservices account', accounts_type, client_factory=cf_accounts) as g:
g.custom_command('create', 'create')
g.command('delete', 'begin_delete')
g.show_command('show', 'get')
Expand All @@ -34,21 +49,40 @@ def load_command_table(self, _):
g.custom_command('list-usage', 'list_usages')
g.custom_command('list-kinds', 'list_kinds', client_factory=cf_resource_skus)

with self.command_group('cognitiveservices account keys', mgmt_type) as g:
with self.command_group('cognitiveservices account keys', accounts_type) as g:
g.command('regenerate', 'regenerate_key')
g.command('list', 'list_keys')

# deprecating this
with self.command_group('cognitiveservices') as g:
with self.command_group('cognitiveservices', client_factory=cf_accounts) as g:
g.custom_command('list', 'list_resources',
deprecate_info=g.deprecate(redirect='az cognitiveservices account list', hide=True))

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

with self.command_group('cognitiveservices account identity', mgmt_type, client_factory=cf_accounts) as g:
with self.command_group('cognitiveservices account identity', accounts_type, client_factory=cf_accounts) as g:
g.custom_command('assign', 'identity_assign')
g.custom_command('remove', 'identity_remove')
g.custom_show_command('show', 'identity_show')

with self.command_group(
'cognitiveservices account deployment', deployments_type,
client_factory=cf_deployments) as g:
g.custom_command('create', 'deployment_begin_create_or_update')
g.command('delete', 'begin_delete')
g.show_command('show', 'get')
g.command('list', 'list')

with self.command_group(
'cognitiveservices account commitment-plan', commitment_plans_type,
client_factory=cf_commitment_plans) as g:
g.custom_command('create', 'commitment_plan_create_or_update')
g.command('delete', 'begin_delete')
g.show_command('show', 'get')
g.command('list', 'list')

with self.command_group('cognitiveservices commitment-tier', commitment_tiers_type) as g:
g.command('list', 'list')
Loading