diff --git a/src/communication/HISTORY.rst b/src/communication/HISTORY.rst new file mode 100644 index 00000000000..1c139576ba0 --- /dev/null +++ b/src/communication/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +0.1.0 +++++++ +* Initial release. diff --git a/src/communication/README.md b/src/communication/README.md new file mode 100644 index 00000000000..5600ffe2dc4 --- /dev/null +++ b/src/communication/README.md @@ -0,0 +1,56 @@ +# Azure CLI communication Extension # +This is the extension for communication + +### How to use ### +Install this extension using the below CLI command +``` +az extension add --name communication +``` + +### Included Features ### +#### communication service #### +##### Create ##### +``` +az communication service create --name "MyCommunicationResource" --location "Global" --data-location "United States" \ + --resource-group "MyResourceGroup" + +az communication service wait --created --name "{myCommunicationService}" --resource-group "{rg}" +``` +##### Show ##### +``` +az communication service show --name "MyCommunicationResource" --resource-group "MyResourceGroup" +``` +##### List ##### +``` +az communication service list --resource-group "MyResourceGroup" +``` +##### Update ##### +``` +az communication service update --name "MyCommunicationResource" --tags newTag="newVal" \ + --resource-group "MyResourceGroup" +``` +##### Link-notification-hub ##### +``` +az communication service link-notification-hub --name "MyCommunicationResource" \ + --connection-string "Endpoint=sb://MyNamespace.servicebus.windows.net/;SharedAccessKey=abcd1234" \ + --resource-id "/subscriptions/12345/resourceGroups/MyOtherResourceGroup/providers/Microsoft.NotificationHubs/namespaces/MyNamespace/notificationHubs/MyHub" \ + --resource-group "MyResourceGroup" +``` +##### List-key ##### +``` +az communication service list-key --name "MyCommunicationResource" --resource-group "MyResourceGroup" +``` +##### Regenerate-key ##### +``` +az communication service regenerate-key --name "MyCommunicationResource" --key-type "Primary" \ + --resource-group "MyResourceGroup" +``` +##### Delete ##### +``` +az communication service delete --name "MyCommunicationResource" --resource-group "MyResourceGroup" +``` +#### communication status #### +##### Show ##### +``` +az communication status show --operation-id "db5f291f-284d-46e9-9152-d5c83f7c14b8" --location "westus2" +``` \ No newline at end of file diff --git a/src/communication/azext_communication/__init__.py b/src/communication/azext_communication/__init__.py new file mode 100644 index 00000000000..5cbd33f6790 --- /dev/null +++ b/src/communication/azext_communication/__init__.py @@ -0,0 +1,50 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader +from azext_communication.generated._help import helps # pylint: disable=unused-import +try: + from azext_communication.manual._help import helps # pylint: disable=reimported +except ImportError: + pass + + +class CommunicationServiceManagementClientCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + from azext_communication.generated._client_factory import cf_communication_cl + communication_custom = CliCommandType( + operations_tmpl='azext_communication.custom#{}', + client_factory=cf_communication_cl) + parent = super(CommunicationServiceManagementClientCommandsLoader, self) + parent.__init__(cli_ctx=cli_ctx, custom_command_type=communication_custom) + + def load_command_table(self, args): + from azext_communication.generated.commands import load_command_table + load_command_table(self, args) + try: + from azext_communication.manual.commands import load_command_table as load_command_table_manual + load_command_table_manual(self, args) + except ImportError: + pass + return self.command_table + + def load_arguments(self, command): + from azext_communication.generated._params import load_arguments + load_arguments(self, command) + try: + from azext_communication.manual._params import load_arguments as load_arguments_manual + load_arguments_manual(self, command) + except ImportError: + pass + + +COMMAND_LOADER_CLS = CommunicationServiceManagementClientCommandsLoader diff --git a/src/communication/azext_communication/action.py b/src/communication/azext_communication/action.py new file mode 100644 index 00000000000..d95d53bf711 --- /dev/null +++ b/src/communication/azext_communication/action.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.action import * # noqa: F403 +try: + from .manual.action import * # noqa: F403 +except ImportError: + pass diff --git a/src/communication/azext_communication/azext_metadata.json b/src/communication/azext_communication/azext_metadata.json new file mode 100644 index 00000000000..d061f35c0c3 --- /dev/null +++ b/src/communication/azext_communication/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isPreview": true, + "azext.minCliCoreVersion": "2.11.0" +} \ No newline at end of file diff --git a/src/communication/azext_communication/custom.py b/src/communication/azext_communication/custom.py new file mode 100644 index 00000000000..dbe9d5f9742 --- /dev/null +++ b/src/communication/azext_communication/custom.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.custom import * # noqa: F403 +try: + from .manual.custom import * # noqa: F403 +except ImportError: + pass diff --git a/src/communication/azext_communication/generated/__init__.py b/src/communication/azext_communication/generated/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/communication/azext_communication/generated/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/communication/azext_communication/generated/_client_factory.py b/src/communication/azext_communication/generated/_client_factory.py new file mode 100644 index 00000000000..aae6721fbb3 --- /dev/null +++ b/src/communication/azext_communication/generated/_client_factory.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + + +def cf_communication_cl(cli_ctx, *_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from ..vendored_sdks.communication import CommunicationServiceManagementClient + return get_mgmt_service_client(cli_ctx, + CommunicationServiceManagementClient) + + +def cf_service(cli_ctx, *_): + return cf_communication_cl(cli_ctx).communication_service + + +def cf_status(cli_ctx, *_): + return cf_communication_cl(cli_ctx).operation_statuses diff --git a/src/communication/azext_communication/generated/_help.py b/src/communication/azext_communication/generated/_help.py new file mode 100644 index 00000000000..5a0f5a19afb --- /dev/null +++ b/src/communication/azext_communication/generated/_help.py @@ -0,0 +1,129 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines + +from knack.help_files import helps + + +helps['communication service'] = """ + type: group + short-summary: communication service +""" + +helps['communication service list'] = """ + type: command + short-summary: "Handles requests to list all resources in a resource group. And Handles requests to list all \ +resources in a subscription." + examples: + - name: List by resource group + text: |- + az communication service list --resource-group "MyResourceGroup" + - name: List by subscription + text: |- + az communication service list +""" + +helps['communication service show'] = """ + type: command + short-summary: "Get the CommunicationService and its properties." + examples: + - name: Get resource + text: |- + az communication service show --name "MyCommunicationResource" --resource-group "MyResourceGroup" +""" + +helps['communication service create'] = """ + type: command + short-summary: "Create a new CommunicationService or update an existing CommunicationService." + examples: + - name: Create or update resource + text: |- + az communication service create --name "MyCommunicationResource" --location "Global" --data-location \ +"United States" --resource-group "MyResourceGroup" +""" + +helps['communication service update'] = """ + type: command + short-summary: "Operation to update an existing CommunicationService." + examples: + - name: Update resource + text: |- + az communication service update --name "MyCommunicationResource" --tags newTag="newVal" \ +--resource-group "MyResourceGroup" +""" + +helps['communication service delete'] = """ + type: command + short-summary: "Operation to delete a CommunicationService." + examples: + - name: Delete resource + text: |- + az communication service delete --name "MyCommunicationResource" --resource-group "MyResourceGroup" +""" + +helps['communication service link-notification-hub'] = """ + type: command + short-summary: "Links an Azure Notification Hub to this communication service." + examples: + - name: Link notification hub + text: |- + az communication service link-notification-hub --name "MyCommunicationResource" --connection-string \ +"Endpoint=sb://MyNamespace.servicebus.windows.net/;SharedAccessKey=abcd1234" --resource-id \ +"/subscriptions/12345/resourceGroups/MyOtherResourceGroup/providers/Microsoft.NotificationHubs/namespaces/MyNamespace/n\ +otificationHubs/MyHub" --resource-group "MyResourceGroup" +""" + +helps['communication service list-key'] = """ + type: command + short-summary: "Get the access keys of the CommunicationService resource." + examples: + - name: List keys + text: |- + az communication service list-key --name "MyCommunicationResource" --resource-group "MyResourceGroup" +""" + +helps['communication service regenerate-key'] = """ + type: command + short-summary: "Regenerate CommunicationService access key. PrimaryKey and SecondaryKey cannot be regenerated at \ +the same time." + examples: + - name: Regenerate key + text: |- + az communication service regenerate-key --name "MyCommunicationResource" --key-type "Primary" \ +--resource-group "MyResourceGroup" +""" + +helps['communication service wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the communication service is met. + examples: + - name: Pause executing next line of CLI script until the communication service is successfully created. + text: |- + az communication service wait --name "MyCommunicationResource" --resource-group "MyResourceGroup" \ +--created + - name: Pause executing next line of CLI script until the communication service is successfully deleted. + text: |- + az communication service wait --name "MyCommunicationResource" --resource-group "MyResourceGroup" \ +--deleted +""" + +helps['communication status'] = """ + type: group + short-summary: communication status +""" + +helps['communication status show'] = """ + type: command + short-summary: "Gets the current status of an async operation." + examples: + - name: Get OperationStatus + text: |- + az communication status show --operation-id "db5f291f-284d-46e9-9152-d5c83f7c14b8" --location "westus2" +""" diff --git a/src/communication/azext_communication/generated/_params.py b/src/communication/azext_communication/generated/_params.py new file mode 100644 index 00000000000..140cf358ab7 --- /dev/null +++ b/src/communication/azext_communication/generated/_params.py @@ -0,0 +1,79 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +from azure.cli.core.commands.parameters import ( + tags_type, + get_enum_type, + resource_group_name_type, + get_location_type +) +from azure.cli.core.commands.validators import get_default_location_from_resource_group + + +def load_arguments(self, _): + + with self.argument_context('communication service list') as c: + c.argument('resource_group_name', resource_group_name_type) + + with self.argument_context('communication service show') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('name', options_list=['--name', '-n'], type=str, help='The name of the CommunicationService ' + 'resource.', id_part='name') + + with self.argument_context('communication service create') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('name', options_list=['--name', '-n'], type=str, help='The name of the CommunicationService ' + 'resource.') + c.argument('location', arg_type=get_location_type(self.cli_ctx), + validator=get_default_location_from_resource_group) + c.argument('tags', tags_type) + c.argument('data_location', type=str, help='The location where the communication service stores its data at ' + 'rest.') + + with self.argument_context('communication service update') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('name', options_list=['--name', '-n'], type=str, help='The name of the CommunicationService ' + 'resource.', id_part='name') + c.argument('tags', tags_type) + + with self.argument_context('communication service delete') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('name', options_list=['--name', '-n'], type=str, help='The name of the CommunicationService ' + 'resource.', id_part='name') + + with self.argument_context('communication service link-notification-hub') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('name', options_list=['--name', '-n'], type=str, help='The name of the CommunicationService ' + 'resource.', id_part='name') + c.argument('resource_id', type=str, help='The resource ID of the notification hub') + c.argument('connection_string', type=str, help='Connection string for the notification hub') + + with self.argument_context('communication service list-key') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('name', options_list=['--name', '-n'], type=str, help='The name of the CommunicationService ' + 'resource.') + + with self.argument_context('communication service regenerate-key') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('name', options_list=['--name', '-n'], type=str, help='The name of the CommunicationService ' + 'resource.', id_part='name') + c.argument('key_type', arg_type=get_enum_type(['Primary', 'Secondary']), help='The keyType to regenerate. Must ' + 'be either \'primary\' or \'secondary\'(case-insensitive).') + + with self.argument_context('communication service wait') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('name', options_list=['--name', '-n'], type=str, help='The name of the CommunicationService ' + 'resource.', id_part='name') + + with self.argument_context('communication status show') as c: + c.argument('location', arg_type=get_location_type(self.cli_ctx)) + c.argument('operation_id', type=str, help='The ID of an ongoing async operation') diff --git a/src/communication/azext_communication/generated/_validators.py b/src/communication/azext_communication/generated/_validators.py new file mode 100644 index 00000000000..b33a44c1ebf --- /dev/null +++ b/src/communication/azext_communication/generated/_validators.py @@ -0,0 +1,9 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- diff --git a/src/communication/azext_communication/generated/action.py b/src/communication/azext_communication/generated/action.py new file mode 100644 index 00000000000..b49bfaeeefe --- /dev/null +++ b/src/communication/azext_communication/generated/action.py @@ -0,0 +1,10 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access diff --git a/src/communication/azext_communication/generated/commands.py b/src/communication/azext_communication/generated/commands.py new file mode 100644 index 00000000000..1bfa8c62087 --- /dev/null +++ b/src/communication/azext_communication/generated/commands.py @@ -0,0 +1,42 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-statements +# pylint: disable=too-many-locals + +from azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): + + from azext_communication.generated._client_factory import cf_service + communication_service = CliCommandType( + operations_tmpl='azext_communication.vendored_sdks.communication.operations._communication_service_operations#C' + 'ommunicationServiceOperations.{}', + client_factory=cf_service) + with self.command_group('communication service', communication_service, client_factory=cf_service, + is_preview=True) as g: + g.custom_command('list', 'communication_service_list') + g.custom_show_command('show', 'communication_service_show') + g.custom_command('create', 'communication_service_create', supports_no_wait=True) + g.custom_command('update', 'communication_service_update') + g.custom_command('delete', 'communication_service_delete', supports_no_wait=True, confirmation=True) + g.custom_command('link-notification-hub', 'communication_service_link_notification_hub') + g.custom_command('list-key', 'communication_service_list_key') + g.custom_command('regenerate-key', 'communication_service_regenerate_key') + g.custom_wait_command('wait', 'communication_service_show') + + from azext_communication.generated._client_factory import cf_status + communication_status = CliCommandType( + operations_tmpl='azext_communication.vendored_sdks.communication.operations._operation_statuses_operations#Oper' + 'ationStatusesOperations.{}', + client_factory=cf_status) + with self.command_group('communication status', communication_status, client_factory=cf_status, + is_preview=True) as g: + g.custom_show_command('show', 'communication_status_show') diff --git a/src/communication/azext_communication/generated/custom.py b/src/communication/azext_communication/generated/custom.py new file mode 100644 index 00000000000..2d83280c105 --- /dev/null +++ b/src/communication/azext_communication/generated/custom.py @@ -0,0 +1,95 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines + +from azure.cli.core.util import sdk_no_wait + + +def communication_service_list(client, + resource_group_name=None): + if resource_group_name: + return client.list_by_resource_group(resource_group_name=resource_group_name) + return client.list_by_subscription() + + +def communication_service_show(client, + resource_group_name, + name): + return client.get(resource_group_name=resource_group_name, + communication_service_name=name) + + +def communication_service_create(client, + resource_group_name, + name, + location=None, + tags=None, + data_location=None, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_create_or_update, + resource_group_name=resource_group_name, + communication_service_name=name, + location=location, + tags=tags, + data_location=data_location) + + +def communication_service_update(client, + resource_group_name, + name, + tags=None): + return client.update(resource_group_name=resource_group_name, + communication_service_name=name, + tags=tags) + + +def communication_service_delete(client, + resource_group_name, + name, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_delete, + resource_group_name=resource_group_name, + communication_service_name=name) + + +def communication_service_link_notification_hub(client, + resource_group_name, + name, + resource_id=None, + connection_string=None): + return client.link_notification_hub(resource_group_name=resource_group_name, + communication_service_name=name, + resource_id=resource_id, + connection_string=connection_string) + + +def communication_service_list_key(client, + resource_group_name, + name): + return client.list_key(resource_group_name=resource_group_name, + communication_service_name=name) + + +def communication_service_regenerate_key(client, + resource_group_name, + name, + key_type=None): + return client.regenerate_key(resource_group_name=resource_group_name, + communication_service_name=name, + key_type=key_type) + + +def communication_status_show(client, + location, + operation_id): + return client.get(location=location, + operation_id=operation_id) diff --git a/src/communication/azext_communication/manual/__init__.py b/src/communication/azext_communication/manual/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/communication/azext_communication/manual/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/communication/azext_communication/tests/__init__.py b/src/communication/azext_communication/tests/__init__.py new file mode 100644 index 00000000000..50e0627daff --- /dev/null +++ b/src/communication/azext_communication/tests/__init__.py @@ -0,0 +1,114 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +import inspect +import logging +import os +import sys +import traceback +import datetime as dt + +from azure.core.exceptions import AzureError +from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError + + +logger = logging.getLogger('azure.cli.testsdk') +logger.addHandler(logging.StreamHandler()) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) +exceptions = [] +test_map = dict() +SUCCESSED = "successed" +FAILED = "failed" + + +def try_manual(func): + def import_manual_function(origin_func): + from importlib import import_module + decorated_path = inspect.getfile(origin_func) + module_path = __path__[0] + if not decorated_path.startswith(module_path): + raise Exception("Decorator can only be used in submodules!") + manual_path = os.path.join( + decorated_path[module_path.rfind(os.path.sep) + 1:]) + manual_file_path, manual_file_name = os.path.split(manual_path) + module_name, _ = os.path.splitext(manual_file_name) + manual_module = "..manual." + \ + ".".join(manual_file_path.split(os.path.sep) + [module_name, ]) + return getattr(import_module(manual_module, package=__name__), origin_func.__name__) + + def get_func_to_call(): + func_to_call = func + try: + func_to_call = import_manual_function(func) + func_to_call = import_manual_function(func) + logger.info("Found manual override for %s(...)", func.__name__) + except (ImportError, AttributeError): + pass + return func_to_call + + def wrapper(*args, **kwargs): + func_to_call = get_func_to_call() + logger.info("running %s()...", func.__name__) + try: + test_map[func.__name__] = dict() + test_map[func.__name__]["result"] = SUCCESSED + test_map[func.__name__]["error_message"] = "" + test_map[func.__name__]["error_stack"] = "" + test_map[func.__name__]["error_normalized"] = "" + test_map[func.__name__]["start_dt"] = dt.datetime.utcnow() + ret = func_to_call(*args, **kwargs) + except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit, + JMESPathCheckAssertionError) as e: + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + test_map[func.__name__]["result"] = FAILED + test_map[func.__name__]["error_message"] = str(e).replace("\r\n", " ").replace("\n", " ")[:500] + test_map[func.__name__]["error_stack"] = traceback.format_exc().replace( + "\r\n", " ").replace("\n", " ")[:500] + logger.info("--------------------------------------") + logger.info("step exception: %s", e) + logger.error("--------------------------------------") + logger.error("step exception in %s: %s", func.__name__, e) + logger.info(traceback.format_exc()) + exceptions.append((func.__name__, sys.exc_info())) + else: + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + return ret + + if inspect.isclass(func): + return get_func_to_call() + return wrapper + + +def calc_coverage(filename): + filename = filename.split(".")[0] + coverage_name = filename + "_coverage.md" + with open(coverage_name, "w") as f: + f.write("|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|\n") + total = len(test_map) + covered = 0 + for k, v in test_map.items(): + if not k.startswith("step_"): + total -= 1 + continue + if v["result"] == SUCCESSED: + covered += 1 + f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|" + "{end_dt}|\n".format(step_name=k, **v)) + f.write("Coverage: {}/{}\n".format(covered, total)) + print("Create coverage\n", file=sys.stderr) + + +def raise_if(): + if exceptions: + if len(exceptions) <= 1: + raise exceptions[0][1][1] + message = "{}\nFollowed with exceptions in other steps:\n".format(str(exceptions[0][1][1])) + message += "\n".join(["{}: {}".format(h[0], h[1][1]) for h in exceptions[1:]]) + raise exceptions[0][1][0](message).with_traceback(exceptions[0][1][2]) diff --git a/src/communication/azext_communication/tests/latest/__init__.py b/src/communication/azext_communication/tests/latest/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/communication/azext_communication/tests/latest/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/communication/azext_communication/tests/latest/test_communication_scenario.py b/src/communication/azext_communication/tests/latest/test_communication_scenario.py new file mode 100644 index 00000000000..c85335b1449 --- /dev/null +++ b/src/communication/azext_communication/tests/latest/test_communication_scenario.py @@ -0,0 +1,183 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import os +from azure.cli.testsdk import ScenarioTest +from .. import try_manual, raise_if, calc_coverage +from azure.cli.testsdk import ResourceGroupPreparer + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +# Env setup +@try_manual +def setup(test, rg_2, rg): + pass + + +# EXAMPLE: /CommunicationService/put/Create or update resource +@try_manual +def step__communicationservice_put(test, rg_2, rg): + test.cmd('az communication service create ' + '--name "{myCommunicationService}" ' + '--location "Global" ' + '--data-location "United States" ' + '--resource-group "{rg}"', + checks=[ + test.check("name", "{myCommunicationService}", case_sensitive=False), + test.check("location", "Global", case_sensitive=False), + test.check("dataLocation", "United States", case_sensitive=False), + ]) + test.cmd('az communication service wait --created ' + '--name "{myCommunicationService}" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /CommunicationService/get/Get resource +@try_manual +def step__communicationservice_get_get_resource(test, rg_2, rg): + test.cmd('az communication service show ' + '--name "{myCommunicationService}" ' + '--resource-group "{rg}"', + checks=[ + test.check("name", "{myCommunicationService}", case_sensitive=False), + test.check("location", "Global", case_sensitive=False), + test.check("dataLocation", "United States", case_sensitive=False), + ]) + + +# EXAMPLE: /CommunicationService/get/List by resource group +@try_manual +def step__communicationservice_get(test, rg_2, rg): + test.cmd('az communication service list ' + '--resource-group "{rg}"', + checks=[ + test.check('length(@)', 1), + ]) + + +# EXAMPLE: /CommunicationService/get/List by subscription +@try_manual +def step__communicationservice_get2(test, rg_2, rg): + test.cmd('az communication service list ' + '-g ""', + checks=[ + test.check('length(@)', 1), + ]) + + +# EXAMPLE: /CommunicationService/patch/Update resource +@try_manual +def step__communicationservice_patch_update_resource(test, rg_2, rg): + test.cmd('az communication service update ' + '--name "{myCommunicationService}" ' + '--tags newTag="newVal" ' + '--resource-group "{rg}"', + checks=[ + test.check("name", "{myCommunicationService}", case_sensitive=False), + test.check("location", "Global", case_sensitive=False), + test.check("dataLocation", "United States", case_sensitive=False), + test.check("tags.newTag", "newVal", case_sensitive=False), + ]) + + +# EXAMPLE: /CommunicationService/post/Link notification hub +@try_manual +def step__communicationservice_post(test, rg_2, rg): + test.cmd('az communication service link-notification-hub ' + '--name "{myCommunicationService}" ' + '--connection-string "Endpoint=sb://MyNamespace.servicebus.windows.net/;SharedAccessKey=abcd1234" ' + '--resource-id "/subscriptions/{subscription_id}/resourceGroups/{rg_2}/providers/Microsoft.NotificationHub' + 's/namespaces/MyNamespace/notificationHubs/MyHub" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /CommunicationService/post/List keys +@try_manual +def step__communicationservice_post_list_keys(test, rg_2, rg): + test.cmd('az communication service list-key ' + '--name "{myCommunicationService}" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /CommunicationService/post/Regenerate key +@try_manual +def step__communicationservice_post_regenerate_key(test, rg_2, rg): + test.cmd('az communication service regenerate-key ' + '--name "{myCommunicationService}" ' + '--key-type "Primary" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /CommunicationService/delete/Delete resource +@try_manual +def step__communicationservice_delete_delete_resource(test, rg_2, rg): + test.cmd('az communication service delete -y ' + '--name "{myCommunicationService}" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /OperationStatuses/get/Get OperationStatus +@try_manual +def step__operationstatuses_get_get_operationstatus(test, rg_2, rg): + test.cmd('az communication status show ' + '--operation-id "db5f291f-284d-46e9-9152-d5c83f7c14b8" ' + '--location "westus2"', + checks=[]) + + +# Env cleanup +@try_manual +def cleanup(test, rg_2, rg): + pass + + +# Testcase +@try_manual +def call_scenario(test, rg_2, rg): + setup(test, rg_2, rg) + step__communicationservice_put(test, rg_2, rg) + step__communicationservice_get_get_resource(test, rg_2, rg) + step__communicationservice_get(test, rg_2, rg) + step__communicationservice_get2(test, rg_2, rg) + step__communicationservice_patch_update_resource(test, rg_2, rg) + step__communicationservice_post(test, rg_2, rg) + step__communicationservice_post_list_keys(test, rg_2, rg) + step__communicationservice_post_regenerate_key(test, rg_2, rg) + step__communicationservice_delete_delete_resource(test, rg_2, rg) + step__operationstatuses_get_get_operationstatus(test, rg_2, rg) + cleanup(test, rg_2, rg) + + +@try_manual +class CommunicationServiceManagementClientScenarioTest(ScenarioTest): + + @ResourceGroupPreparer(name_prefix='clitestcommunication_MyOtherResourceGroup'[:7], key='rg_2', parameter_name='' + 'rg_2') + @ResourceGroupPreparer(name_prefix='clitestcommunication_MyResourceGroup'[:7], key='rg', parameter_name='rg') + def test_communication(self, rg_2, rg): + + self.kwargs.update({ + 'subscription_id': self.get_subscription_id() + }) + + self.kwargs.update({ + 'myCommunicationService': 'MyCommunicationResource', + }) + + call_scenario(self, rg_2, rg) + calc_coverage(__file__) + raise_if() diff --git a/src/communication/azext_communication/vendored_sdks/__init__.py b/src/communication/azext_communication/vendored_sdks/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/communication/azext_communication/vendored_sdks/communication/__init__.py b/src/communication/azext_communication/vendored_sdks/communication/__init__.py new file mode 100644 index 00000000000..8d413db78e1 --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/__init__.py @@ -0,0 +1,16 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._communication_service_management_client import CommunicationServiceManagementClient +__all__ = ['CommunicationServiceManagementClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/src/communication/azext_communication/vendored_sdks/communication/_communication_service_management_client.py b/src/communication/azext_communication/vendored_sdks/communication/_communication_service_management_client.py new file mode 100644 index 00000000000..93563627cfb --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/_communication_service_management_client.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + +from ._configuration import CommunicationServiceManagementClientConfiguration +from .operations import OperationOperations +from .operations import CommunicationServiceOperations +from .operations import OperationStatusesOperations +from . import models + + +class CommunicationServiceManagementClient(object): + """REST API for Azure Communication Services. + + :ivar operation: OperationOperations operations + :vartype operation: communication_service_management_client.operations.OperationOperations + :ivar communication_service: CommunicationServiceOperations operations + :vartype communication_service: communication_service_management_client.operations.CommunicationServiceOperations + :ivar operation_statuses: OperationStatusesOperations operations + :vartype operation_statuses: communication_service_management_client.operations.OperationStatusesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = CommunicationServiceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.communication_service = CommunicationServiceOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operation_statuses = OperationStatusesOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> CommunicationServiceManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/src/communication/azext_communication/vendored_sdks/communication/_configuration.py b/src/communication/azext_communication/vendored_sdks/communication/_configuration.py new file mode 100644 index 00000000000..800d9f9e817 --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/_configuration.py @@ -0,0 +1,70 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class CommunicationServiceManagementClientConfiguration(Configuration): + """Configuration for CommunicationServiceManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(CommunicationServiceManagementClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-08-20-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'communicationservicemanagementclient/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/communication/azext_communication/vendored_sdks/communication/aio/__init__.py b/src/communication/azext_communication/vendored_sdks/communication/aio/__init__.py new file mode 100644 index 00000000000..07c2fa03a1d --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._communication_service_management_client import CommunicationServiceManagementClient +__all__ = ['CommunicationServiceManagementClient'] diff --git a/src/communication/azext_communication/vendored_sdks/communication/aio/_communication_service_management_client.py b/src/communication/azext_communication/vendored_sdks/communication/aio/_communication_service_management_client.py new file mode 100644 index 00000000000..2c21997f36b --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/aio/_communication_service_management_client.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import CommunicationServiceManagementClientConfiguration +from .operations import OperationOperations +from .operations import CommunicationServiceOperations +from .operations import OperationStatusesOperations +from .. import models + + +class CommunicationServiceManagementClient(object): + """REST API for Azure Communication Services. + + :ivar operation: OperationOperations operations + :vartype operation: communication_service_management_client.aio.operations.OperationOperations + :ivar communication_service: CommunicationServiceOperations operations + :vartype communication_service: communication_service_management_client.aio.operations.CommunicationServiceOperations + :ivar operation_statuses: OperationStatusesOperations operations + :vartype operation_statuses: communication_service_management_client.aio.operations.OperationStatusesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = CommunicationServiceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.communication_service = CommunicationServiceOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operation_statuses = OperationStatusesOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "CommunicationServiceManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/src/communication/azext_communication/vendored_sdks/communication/aio/_configuration.py b/src/communication/azext_communication/vendored_sdks/communication/aio/_configuration.py new file mode 100644 index 00000000000..5398ab08c0d --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/aio/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + +class CommunicationServiceManagementClientConfiguration(Configuration): + """Configuration for CommunicationServiceManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(CommunicationServiceManagementClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-08-20-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'communicationservicemanagementclient/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/communication/azext_communication/vendored_sdks/communication/aio/operations/__init__.py b/src/communication/azext_communication/vendored_sdks/communication/aio/operations/__init__.py new file mode 100644 index 00000000000..34e927cfe39 --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/aio/operations/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operation_operations import OperationOperations +from ._communication_service_operations import CommunicationServiceOperations +from ._operation_statuses_operations import OperationStatusesOperations + +__all__ = [ + 'OperationOperations', + 'CommunicationServiceOperations', + 'OperationStatusesOperations', +] diff --git a/src/communication/azext_communication/vendored_sdks/communication/aio/operations/_communication_service_operations.py b/src/communication/azext_communication/vendored_sdks/communication/aio/operations/_communication_service_operations.py new file mode 100644 index 00000000000..63a76db65cb --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/aio/operations/_communication_service_operations.py @@ -0,0 +1,884 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CommunicationServiceOperations: + """CommunicationServiceOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~communication_service_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def check_name_availability( + self, + type: Optional[str] = None, + name: Optional[str] = None, + **kwargs + ) -> "models.NameAvailability": + """Check Name Availability. + + Checks that the CommunicationService name is valid and is not already in use. + + :param type: The resource type. Should be always + "Microsoft.Communication/CommunicationServices". + :type type: str + :param name: The CommunicationService name to validate. e.g."my-CommunicationService-name- + here". + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NameAvailability, or the result of cls(response) + :rtype: ~communication_service_management_client.models.NameAvailability + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.NameAvailability"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + name_availability_parameters = models.NameAvailabilityParameters(type=type, name=name) + api_version = "2020-08-20-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_name_availability.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if name_availability_parameters is not None: + body_content = self._serialize.body(name_availability_parameters, 'NameAvailabilityParameters') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('NameAvailability', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Communication/checkNameAvailability'} # type: ignore + + async def link_notification_hub( + self, + resource_group_name: str, + communication_service_name: str, + resource_id: Optional[str] = None, + connection_string: Optional[str] = None, + **kwargs + ) -> "models.LinkedNotificationHub": + """Link Notification Hub. + + Links an Azure Notification Hub to this communication service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param communication_service_name: The name of the CommunicationService resource. + :type communication_service_name: str + :param resource_id: The resource ID of the notification hub. + :type resource_id: str + :param connection_string: Connection string for the notification hub. + :type connection_string: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LinkedNotificationHub, or the result of cls(response) + :rtype: ~communication_service_management_client.models.LinkedNotificationHub + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LinkedNotificationHub"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + link_notification_hub_parameters = models.LinkNotificationHubParameters(resource_id=resource_id, connection_string=connection_string) + api_version = "2020-08-20-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.link_notification_hub.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if link_notification_hub_parameters is not None: + body_content = self._serialize.body(link_notification_hub_parameters, 'LinkNotificationHubParameters') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LinkedNotificationHub', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + link_notification_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}/linkNotificationHub'} # type: ignore + + def list_by_subscription( + self, + **kwargs + ) -> AsyncIterable["models.CommunicationServiceResourceList"]: + """List By Subscription. + + Handles requests to list all resources in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CommunicationServiceResourceList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~communication_service_management_client.models.CommunicationServiceResourceList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationServiceResourceList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-20-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('CommunicationServiceResourceList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Communication/communicationServices'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["models.CommunicationServiceResourceList"]: + """List By Resource Group. + + Handles requests to list all resources in a resource group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CommunicationServiceResourceList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~communication_service_management_client.models.CommunicationServiceResourceList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationServiceResourceList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-20-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('CommunicationServiceResourceList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices'} # type: ignore + + async def update( + self, + resource_group_name: str, + communication_service_name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ) -> "models.CommunicationServiceResource": + """Update. + + Operation to update an existing CommunicationService. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param communication_service_name: The name of the CommunicationService resource. + :type communication_service_name: str + :param tags: Tags of the service which is a list of key value pairs that describe the resource. + :type tags: dict[str, str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunicationServiceResource, or the result of cls(response) + :rtype: ~communication_service_management_client.models.CommunicationServiceResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationServiceResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + parameters = models.TaggedResource(tags=tags) + api_version = "2020-08-20-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if parameters is not None: + body_content = self._serialize.body(parameters, 'TaggedResource') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CommunicationServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + communication_service_name: str, + **kwargs + ) -> "models.CommunicationServiceResource": + """Get. + + Get the CommunicationService and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param communication_service_name: The name of the CommunicationService resource. + :type communication_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunicationServiceResource, or the result of cls(response) + :rtype: ~communication_service_management_client.models.CommunicationServiceResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationServiceResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-20-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CommunicationServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + communication_service_name: str, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + data_location: Optional[str] = None, + **kwargs + ) -> "models.CommunicationServiceResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationServiceResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + parameters = models.CommunicationServiceResource(location=location, tags=tags, data_location=data_location) + api_version = "2020-08-20-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if parameters is not None: + body_content = self._serialize.body(parameters, 'CommunicationServiceResource') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('CommunicationServiceResource', pipeline_response) + + if response.status_code == 201: + response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('CommunicationServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + communication_service_name: str, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + data_location: Optional[str] = None, + **kwargs + ) -> AsyncLROPoller["models.CommunicationServiceResource"]: + """Create Or Update. + + Create a new CommunicationService or update an existing CommunicationService. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param communication_service_name: The name of the CommunicationService resource. + :type communication_service_name: str + :param location: The Azure location where the CommunicationService is running. + :type location: str + :param tags: Tags of the service which is a list of key value pairs that describe the resource. + :type tags: dict[str, str] + :param data_location: The location where the communication service stores its data at rest. + :type data_location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CommunicationServiceResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~communication_service_management_client.models.CommunicationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationServiceResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + communication_service_name=communication_service_name, + location=location, + tags=tags, + data_location=data_location, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('CommunicationServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + communication_service_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-20-preview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + communication_service_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Delete. + + Operation to delete a CommunicationService. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param communication_service_name: The name of the CommunicationService resource. + :type communication_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + communication_service_name=communication_service_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}'} # type: ignore + + async def list_key( + self, + resource_group_name: str, + communication_service_name: str, + **kwargs + ) -> "models.CommunicationServiceKeys": + """List Keys. + + Get the access keys of the CommunicationService resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param communication_service_name: The name of the CommunicationService resource. + :type communication_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunicationServiceKeys, or the result of cls(response) + :rtype: ~communication_service_management_client.models.CommunicationServiceKeys + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationServiceKeys"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-20-preview" + accept = "application/json" + + # Construct URL + url = self.list_key.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CommunicationServiceKeys', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}/listKeys'} # type: ignore + + async def regenerate_key( + self, + resource_group_name: str, + communication_service_name: str, + key_type: Optional[Union[str, "models.KeyType"]] = None, + **kwargs + ) -> "models.CommunicationServiceKeys": + """Regenerate Key. + + Regenerate CommunicationService access key. PrimaryKey and SecondaryKey cannot be regenerated + at the same time. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param communication_service_name: The name of the CommunicationService resource. + :type communication_service_name: str + :param key_type: The keyType to regenerate. Must be either 'primary' or 'secondary'(case- + insensitive). + :type key_type: str or ~communication_service_management_client.models.KeyType + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunicationServiceKeys, or the result of cls(response) + :rtype: ~communication_service_management_client.models.CommunicationServiceKeys + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationServiceKeys"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + parameters = models.RegenerateKeyParameters(key_type=key_type) + api_version = "2020-08-20-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.regenerate_key.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if parameters is not None: + body_content = self._serialize.body(parameters, 'RegenerateKeyParameters') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('CommunicationServiceKeys', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('CommunicationServiceKeys', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}/regenerateKey'} # type: ignore diff --git a/src/communication/azext_communication/vendored_sdks/communication/aio/operations/_operation_operations.py b/src/communication/azext_communication/vendored_sdks/communication/aio/operations/_operation_operations.py new file mode 100644 index 00000000000..a9a224fe7d3 --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/aio/operations/_operation_operations.py @@ -0,0 +1,107 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations: + """OperationOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~communication_service_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationList"]: + """List Operations. + + Lists all of the available REST API operations of the Microsoft.Communication provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~communication_service_management_client.models.OperationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-20-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Communication/operations'} # type: ignore diff --git a/src/communication/azext_communication/vendored_sdks/communication/aio/operations/_operation_statuses_operations.py b/src/communication/azext_communication/vendored_sdks/communication/aio/operations/_operation_statuses_operations.py new file mode 100644 index 00000000000..bfa993e7b8f --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/aio/operations/_operation_statuses_operations.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class OperationStatusesOperations: + """OperationStatusesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~communication_service_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + location: str, + operation_id: str, + **kwargs + ) -> "models.OperationStatus": + """Get Operation Status. + + Gets the current status of an async operation. + + :param location: The Azure region. + :type location: str + :param operation_id: The ID of an ongoing async operation. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatus, or the result of cls(response) + :rtype: ~communication_service_management_client.models.OperationStatus + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationStatus"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-20-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'location': self._serialize.url("location", location, 'str'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('OperationStatus', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Communication/locations/{location}/operationStatuses/{operationId}'} # type: ignore diff --git a/src/communication/azext_communication/vendored_sdks/communication/models/__init__.py b/src/communication/azext_communication/vendored_sdks/communication/models/__init__.py new file mode 100644 index 00000000000..9b1c0f734ca --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/models/__init__.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import CommunicationServiceKeys + from ._models_py3 import CommunicationServiceResource + from ._models_py3 import CommunicationServiceResourceList + from ._models_py3 import Dimension + from ._models_py3 import ErrorResponse + from ._models_py3 import ErrorResponseError + from ._models_py3 import LinkNotificationHubParameters + from ._models_py3 import LinkedNotificationHub + from ._models_py3 import LocationResource + from ._models_py3 import MetricSpecification + from ._models_py3 import NameAvailability + from ._models_py3 import NameAvailabilityParameters + from ._models_py3 import Operation + from ._models_py3 import OperationDisplay + from ._models_py3 import OperationList + from ._models_py3 import OperationProperties + from ._models_py3 import OperationStatus + from ._models_py3 import RegenerateKeyParameters + from ._models_py3 import Resource + from ._models_py3 import ServiceSpecification + from ._models_py3 import TaggedResource +except (SyntaxError, ImportError): + from ._models import CommunicationServiceKeys # type: ignore + from ._models import CommunicationServiceResource # type: ignore + from ._models import CommunicationServiceResourceList # type: ignore + from ._models import Dimension # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ErrorResponseError # type: ignore + from ._models import LinkNotificationHubParameters # type: ignore + from ._models import LinkedNotificationHub # type: ignore + from ._models import LocationResource # type: ignore + from ._models import MetricSpecification # type: ignore + from ._models import NameAvailability # type: ignore + from ._models import NameAvailabilityParameters # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationList # type: ignore + from ._models import OperationProperties # type: ignore + from ._models import OperationStatus # type: ignore + from ._models import RegenerateKeyParameters # type: ignore + from ._models import Resource # type: ignore + from ._models import ServiceSpecification # type: ignore + from ._models import TaggedResource # type: ignore + +from ._communication_service_management_client_enums import ( + AggregationType, + KeyType, + ProvisioningState, + Status, +) + +__all__ = [ + 'CommunicationServiceKeys', + 'CommunicationServiceResource', + 'CommunicationServiceResourceList', + 'Dimension', + 'ErrorResponse', + 'ErrorResponseError', + 'LinkNotificationHubParameters', + 'LinkedNotificationHub', + 'LocationResource', + 'MetricSpecification', + 'NameAvailability', + 'NameAvailabilityParameters', + 'Operation', + 'OperationDisplay', + 'OperationList', + 'OperationProperties', + 'OperationStatus', + 'RegenerateKeyParameters', + 'Resource', + 'ServiceSpecification', + 'TaggedResource', + 'AggregationType', + 'KeyType', + 'ProvisioningState', + 'Status', +] diff --git a/src/communication/azext_communication/vendored_sdks/communication/models/_communication_service_management_client_enums.py b/src/communication/azext_communication/vendored_sdks/communication/models/_communication_service_management_client_enums.py new file mode 100644 index 00000000000..d7eeddc32d0 --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/models/_communication_service_management_client_enums.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class AggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The method for aggregating the metric. + """ + + AVERAGE = "Average" + MINIMUM = "Minimum" + MAXIMUM = "Maximum" + TOTAL = "Total" + COUNT = "Count" + +class KeyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The keyType to regenerate. Must be either 'primary' or 'secondary'(case-insensitive). + """ + + PRIMARY = "Primary" + SECONDARY = "Secondary" + +class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Provisioning state of the resource. + """ + + UNKNOWN = "Unknown" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + RUNNING = "Running" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + MOVING = "Moving" + +class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Provisioning state of the resource. + """ + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + CREATING = "Creating" + DELETING = "Deleting" + MOVING = "Moving" diff --git a/src/communication/azext_communication/vendored_sdks/communication/models/_models.py b/src/communication/azext_communication/vendored_sdks/communication/models/_models.py new file mode 100644 index 00000000000..959f9c5ad2b --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/models/_models.py @@ -0,0 +1,670 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class CommunicationServiceKeys(msrest.serialization.Model): + """A class representing the access keys of a CommunicationService. + + :param primary_key: The primary access key. + :type primary_key: str + :param secondary_key: The secondary access key. + :type secondary_key: str + :param primary_connection_string: CommunicationService connection string constructed via the + primaryKey. + :type primary_connection_string: str + :param secondary_connection_string: CommunicationService connection string constructed via the + secondaryKey. + :type secondary_connection_string: str + """ + + _attribute_map = { + 'primary_key': {'key': 'primaryKey', 'type': 'str'}, + 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, + 'primary_connection_string': {'key': 'primaryConnectionString', 'type': 'str'}, + 'secondary_connection_string': {'key': 'secondaryConnectionString', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CommunicationServiceKeys, self).__init__(**kwargs) + self.primary_key = kwargs.get('primary_key', None) + self.secondary_key = kwargs.get('secondary_key', None) + self.primary_connection_string = kwargs.get('primary_connection_string', None) + self.secondary_connection_string = kwargs.get('secondary_connection_string', None) + + +class TaggedResource(msrest.serialization.Model): + """An ARM resource with that can accept tags. + + :param tags: A set of tags. Tags of the service which is a list of key value pairs that + describe the resource. + :type tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(TaggedResource, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + + +class LocationResource(msrest.serialization.Model): + """An ARM resource with its own location (not a global or an inherited location). + + :param location: The Azure location where the CommunicationService is running. + :type location: str + """ + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LocationResource, self).__init__(**kwargs) + self.location = kwargs.get('location', None) + + +class Resource(msrest.serialization.Model): + """The core properties of ARM resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the service - e.g. "Microsoft.Communication/CommunicationServices". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class CommunicationServiceResource(Resource, LocationResource, TaggedResource): + """A class representing a CommunicationService resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param tags: A set of tags. Tags of the service which is a list of key value pairs that + describe the resource. + :type tags: dict[str, str] + :param location: The Azure location where the CommunicationService is running. + :type location: str + :ivar id: Fully qualified resource ID for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the service - e.g. "Microsoft.Communication/CommunicationServices". + :vartype type: str + :ivar provisioning_state: Provisioning state of the resource. Possible values include: + "Unknown", "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", + "Moving". + :vartype provisioning_state: str or + ~communication_service_management_client.models.ProvisioningState + :ivar host_name: FQDN of the CommunicationService instance. + :vartype host_name: str + :param data_location: The location where the communication service stores its data at rest. + :type data_location: str + :ivar notification_hub_id: Resource ID of an Azure Notification Hub linked to this resource. + :vartype notification_hub_id: str + :ivar version: Version of the CommunicationService resource. Probably you need the same or + higher version of client SDKs. + :vartype version: str + :ivar immutable_resource_id: The immutable resource Id of the communication service. + :vartype immutable_resource_id: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'host_name': {'readonly': True}, + 'notification_hub_id': {'readonly': True}, + 'version': {'readonly': True}, + 'immutable_resource_id': {'readonly': True}, + } + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'host_name': {'key': 'properties.hostName', 'type': 'str'}, + 'data_location': {'key': 'properties.dataLocation', 'type': 'str'}, + 'notification_hub_id': {'key': 'properties.notificationHubId', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'immutable_resource_id': {'key': 'properties.immutableResourceId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CommunicationServiceResource, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + self.location = kwargs.get('location', None) + self.provisioning_state = None + self.host_name = None + self.data_location = kwargs.get('data_location', None) + self.notification_hub_id = None + self.version = None + self.immutable_resource_id = None + self.tags = kwargs.get('tags', None) + self.id = None + self.name = None + self.type = None + self.provisioning_state = None + self.host_name = None + self.data_location = kwargs.get('data_location', None) + self.notification_hub_id = None + self.version = None + self.immutable_resource_id = None + self.location = kwargs.get('location', None) + self.id = None + self.name = None + self.type = None + self.provisioning_state = None + self.host_name = None + self.data_location = kwargs.get('data_location', None) + self.notification_hub_id = None + self.version = None + self.immutable_resource_id = None + + +class CommunicationServiceResourceList(msrest.serialization.Model): + """Object that includes an array of CommunicationServices and a possible link for next set. + + :param value: List of CommunicationService. + :type value: list[~communication_service_management_client.models.CommunicationServiceResource] + :param next_link: The URL the client should use to fetch the next page (per server side + paging). + It's null for now, added for future use. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CommunicationServiceResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CommunicationServiceResourceList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class Dimension(msrest.serialization.Model): + """Specifications of the Dimension of metrics. + + :param name: The public facing name of the dimension. + :type name: str + :param display_name: Localized friendly display name of the dimension. + :type display_name: str + :param internal_name: Name of the dimension as it appears in MDM. + :type internal_name: str + :param to_be_exported_for_shoebox: A Boolean flag indicating whether this dimension should be + included for the shoebox export scenario. + :type to_be_exported_for_shoebox: bool + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'internal_name': {'key': 'internalName', 'type': 'str'}, + 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + super(Dimension, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display_name = kwargs.get('display_name', None) + self.internal_name = kwargs.get('internal_name', None) + self.to_be_exported_for_shoebox = kwargs.get('to_be_exported_for_shoebox', None) + + +class ErrorResponse(msrest.serialization.Model): + """Error response indicating why the requested operation could not be performed. + + :param error: The error. + :type error: ~communication_service_management_client.models.ErrorResponseError + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class ErrorResponseError(msrest.serialization.Model): + """The error. + + :param code: Error code. + :type code: str + :param message: Error message indicating why the operation failed. + :type message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponseError, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + + +class LinkedNotificationHub(msrest.serialization.Model): + """A notification hub that has been linked to the communication service. + + :param resource_id: The resource ID of the notification hub. + :type resource_id: str + """ + + _attribute_map = { + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LinkedNotificationHub, self).__init__(**kwargs) + self.resource_id = kwargs.get('resource_id', None) + + +class LinkNotificationHubParameters(msrest.serialization.Model): + """Description of an Azure Notification Hub to link to the communication service. + + All required parameters must be populated in order to send to Azure. + + :param resource_id: Required. The resource ID of the notification hub. + :type resource_id: str + :param connection_string: Required. Connection string for the notification hub. + :type connection_string: str + """ + + _validation = { + 'resource_id': {'required': True}, + 'connection_string': {'required': True}, + } + + _attribute_map = { + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'connection_string': {'key': 'connectionString', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LinkNotificationHubParameters, self).__init__(**kwargs) + self.resource_id = kwargs['resource_id'] + self.connection_string = kwargs['connection_string'] + + +class MetricSpecification(msrest.serialization.Model): + """Specifications of the Metrics for Azure Monitoring. + + :param name: Name of the metric. + :type name: str + :param display_name: Localized friendly display name of the metric. + :type display_name: str + :param display_description: Localized friendly description of the metric. + :type display_description: str + :param unit: The unit that makes sense for the metric. + :type unit: str + :param aggregation_type: The method for aggregating the metric. Possible values include: + "Average", "Minimum", "Maximum", "Total", "Count". + :type aggregation_type: str or ~communication_service_management_client.models.AggregationType + :param fill_gap_with_zero: Optional. If set to true, then zero will be returned for time + duration where no metric is emitted/published. + Ex. a metric that returns the number of times a particular error code was emitted. The error + code may not appear + often, instead of the RP publishing 0, Shoebox can auto fill in 0s for time periods where + nothing was emitted. + :type fill_gap_with_zero: str + :param category: The name of the metric category that the metric belongs to. A metric can only + belong to a single category. + :type category: str + :param dimensions: The dimensions of the metrics. + :type dimensions: list[~communication_service_management_client.models.Dimension] + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'display_description': {'key': 'displayDescription', 'type': 'str'}, + 'unit': {'key': 'unit', 'type': 'str'}, + 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, + 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'str'}, + 'category': {'key': 'category', 'type': 'str'}, + 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, + } + + def __init__( + self, + **kwargs + ): + super(MetricSpecification, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display_name = kwargs.get('display_name', None) + self.display_description = kwargs.get('display_description', None) + self.unit = kwargs.get('unit', None) + self.aggregation_type = kwargs.get('aggregation_type', None) + self.fill_gap_with_zero = kwargs.get('fill_gap_with_zero', None) + self.category = kwargs.get('category', None) + self.dimensions = kwargs.get('dimensions', None) + + +class NameAvailability(msrest.serialization.Model): + """Result of the request to check name availability. It contains a flag and possible reason of failure. + + :param name_available: Indicates whether the name is available or not. + :type name_available: bool + :param reason: The reason of the availability. Required if name is not available. + :type reason: str + :param message: The message of the operation. + :type message: str + """ + + _attribute_map = { + 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(NameAvailability, self).__init__(**kwargs) + self.name_available = kwargs.get('name_available', None) + self.reason = kwargs.get('reason', None) + self.message = kwargs.get('message', None) + + +class NameAvailabilityParameters(msrest.serialization.Model): + """Data POST-ed to the nameAvailability action. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. The resource type. Should be always + "Microsoft.Communication/CommunicationServices". + :type type: str + :param name: Required. The CommunicationService name to validate. e.g."my-CommunicationService- + name-here". + :type name: str + """ + + _validation = { + 'type': {'required': True}, + 'name': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(NameAvailabilityParameters, self).__init__(**kwargs) + self.type = kwargs['type'] + self.name = kwargs['name'] + + +class Operation(msrest.serialization.Model): + """REST API operation supported by CommunicationService resource provider. + + :param name: Name of the operation with format: {provider}/{resource}/{operation}. + :type name: str + :param display: The object that describes the operation. + :type display: ~communication_service_management_client.models.OperationDisplay + :param origin: Optional. The intended executor of the operation; governs the display of the + operation in the RBAC UX and the audit logs UX. + :type origin: str + :param properties: Extra properties for the operation. + :type properties: ~communication_service_management_client.models.OperationProperties + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'OperationProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) + self.origin = kwargs.get('origin', None) + self.properties = kwargs.get('properties', None) + + +class OperationDisplay(msrest.serialization.Model): + """The object that describes a operation. + + :param provider: Friendly name of the resource provider. + :type provider: str + :param resource: Resource type on which the operation is performed. + :type resource: str + :param operation: The localized friendly name for the operation. + :type operation: str + :param description: The localized friendly description for the operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = kwargs.get('provider', None) + self.resource = kwargs.get('resource', None) + self.operation = kwargs.get('operation', None) + self.description = kwargs.get('description', None) + + +class OperationList(msrest.serialization.Model): + """Result of the request to list REST API operations. It contains a list of operations. + + :param value: List of operations supported by the resource provider. + :type value: list[~communication_service_management_client.models.Operation] + :param next_link: The URL the client should use to fetch the next page (per server side + paging). + It's null for now, added for future use. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class OperationProperties(msrest.serialization.Model): + """Extra Operation properties. + + :param service_specification: The service specifications. + :type service_specification: + ~communication_service_management_client.models.ServiceSpecification + """ + + _attribute_map = { + 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationProperties, self).__init__(**kwargs) + self.service_specification = kwargs.get('service_specification', None) + + +class OperationStatus(msrest.serialization.Model): + """The current status of an async operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified ID for the operation status. + :vartype id: str + :ivar status: Provisioning state of the resource. Possible values include: "Succeeded", + "Failed", "Canceled", "Creating", "Deleting", "Moving". + :vartype status: str or ~communication_service_management_client.models.Status + :ivar start_time: The start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the operation. + :vartype end_time: ~datetime.datetime + :ivar percent_complete: Percent of the operation that is complete. + :vartype percent_complete: float + :param error: The error. + :type error: ~communication_service_management_client.models.ErrorResponseError + """ + + _validation = { + 'id': {'readonly': True}, + 'status': {'readonly': True}, + 'start_time': {'readonly': True}, + 'end_time': {'readonly': True}, + 'percent_complete': {'readonly': True, 'maximum': 100, 'minimum': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, + 'percent_complete': {'key': 'percentComplete', 'type': 'float'}, + 'error': {'key': 'error.error', 'type': 'ErrorResponseError'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationStatus, self).__init__(**kwargs) + self.id = None + self.status = None + self.start_time = None + self.end_time = None + self.percent_complete = None + self.error = kwargs.get('error', None) + + +class RegenerateKeyParameters(msrest.serialization.Model): + """Parameters describes the request to regenerate access keys. + + :param key_type: The keyType to regenerate. Must be either 'primary' or 'secondary'(case- + insensitive). Possible values include: "Primary", "Secondary". + :type key_type: str or ~communication_service_management_client.models.KeyType + """ + + _attribute_map = { + 'key_type': {'key': 'keyType', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(RegenerateKeyParameters, self).__init__(**kwargs) + self.key_type = kwargs.get('key_type', None) + + +class ServiceSpecification(msrest.serialization.Model): + """An object that describes a specification. + + :param metric_specifications: Specifications of the Metrics for Azure Monitoring. + :type metric_specifications: + list[~communication_service_management_client.models.MetricSpecification] + """ + + _attribute_map = { + 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + } + + def __init__( + self, + **kwargs + ): + super(ServiceSpecification, self).__init__(**kwargs) + self.metric_specifications = kwargs.get('metric_specifications', None) diff --git a/src/communication/azext_communication/vendored_sdks/communication/models/_models_py3.py b/src/communication/azext_communication/vendored_sdks/communication/models/_models_py3.py new file mode 100644 index 00000000000..4218612797e --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/models/_models_py3.py @@ -0,0 +1,742 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._communication_service_management_client_enums import * + + +class CommunicationServiceKeys(msrest.serialization.Model): + """A class representing the access keys of a CommunicationService. + + :param primary_key: The primary access key. + :type primary_key: str + :param secondary_key: The secondary access key. + :type secondary_key: str + :param primary_connection_string: CommunicationService connection string constructed via the + primaryKey. + :type primary_connection_string: str + :param secondary_connection_string: CommunicationService connection string constructed via the + secondaryKey. + :type secondary_connection_string: str + """ + + _attribute_map = { + 'primary_key': {'key': 'primaryKey', 'type': 'str'}, + 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, + 'primary_connection_string': {'key': 'primaryConnectionString', 'type': 'str'}, + 'secondary_connection_string': {'key': 'secondaryConnectionString', 'type': 'str'}, + } + + def __init__( + self, + *, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + primary_connection_string: Optional[str] = None, + secondary_connection_string: Optional[str] = None, + **kwargs + ): + super(CommunicationServiceKeys, self).__init__(**kwargs) + self.primary_key = primary_key + self.secondary_key = secondary_key + self.primary_connection_string = primary_connection_string + self.secondary_connection_string = secondary_connection_string + + +class TaggedResource(msrest.serialization.Model): + """An ARM resource with that can accept tags. + + :param tags: A set of tags. Tags of the service which is a list of key value pairs that + describe the resource. + :type tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(TaggedResource, self).__init__(**kwargs) + self.tags = tags + + +class LocationResource(msrest.serialization.Model): + """An ARM resource with its own location (not a global or an inherited location). + + :param location: The Azure location where the CommunicationService is running. + :type location: str + """ + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + **kwargs + ): + super(LocationResource, self).__init__(**kwargs) + self.location = location + + +class Resource(msrest.serialization.Model): + """The core properties of ARM resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the service - e.g. "Microsoft.Communication/CommunicationServices". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class CommunicationServiceResource(Resource, LocationResource, TaggedResource): + """A class representing a CommunicationService resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param tags: A set of tags. Tags of the service which is a list of key value pairs that + describe the resource. + :type tags: dict[str, str] + :param location: The Azure location where the CommunicationService is running. + :type location: str + :ivar id: Fully qualified resource ID for the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the service - e.g. "Microsoft.Communication/CommunicationServices". + :vartype type: str + :ivar provisioning_state: Provisioning state of the resource. Possible values include: + "Unknown", "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", + "Moving". + :vartype provisioning_state: str or + ~communication_service_management_client.models.ProvisioningState + :ivar host_name: FQDN of the CommunicationService instance. + :vartype host_name: str + :param data_location: The location where the communication service stores its data at rest. + :type data_location: str + :ivar notification_hub_id: Resource ID of an Azure Notification Hub linked to this resource. + :vartype notification_hub_id: str + :ivar version: Version of the CommunicationService resource. Probably you need the same or + higher version of client SDKs. + :vartype version: str + :ivar immutable_resource_id: The immutable resource Id of the communication service. + :vartype immutable_resource_id: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'host_name': {'readonly': True}, + 'notification_hub_id': {'readonly': True}, + 'version': {'readonly': True}, + 'immutable_resource_id': {'readonly': True}, + } + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'host_name': {'key': 'properties.hostName', 'type': 'str'}, + 'data_location': {'key': 'properties.dataLocation', 'type': 'str'}, + 'notification_hub_id': {'key': 'properties.notificationHubId', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'immutable_resource_id': {'key': 'properties.immutableResourceId', 'type': 'str'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + data_location: Optional[str] = None, + **kwargs + ): + super(CommunicationServiceResource, self).__init__(location=location, tags=tags, **kwargs) + self.tags = tags + self.location = location + self.provisioning_state = None + self.host_name = None + self.data_location = data_location + self.notification_hub_id = None + self.version = None + self.immutable_resource_id = None + self.tags = tags + self.id = None + self.name = None + self.type = None + self.provisioning_state = None + self.host_name = None + self.data_location = data_location + self.notification_hub_id = None + self.version = None + self.immutable_resource_id = None + self.location = location + self.id = None + self.name = None + self.type = None + self.provisioning_state = None + self.host_name = None + self.data_location = data_location + self.notification_hub_id = None + self.version = None + self.immutable_resource_id = None + + +class CommunicationServiceResourceList(msrest.serialization.Model): + """Object that includes an array of CommunicationServices and a possible link for next set. + + :param value: List of CommunicationService. + :type value: list[~communication_service_management_client.models.CommunicationServiceResource] + :param next_link: The URL the client should use to fetch the next page (per server side + paging). + It's null for now, added for future use. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CommunicationServiceResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["CommunicationServiceResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(CommunicationServiceResourceList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Dimension(msrest.serialization.Model): + """Specifications of the Dimension of metrics. + + :param name: The public facing name of the dimension. + :type name: str + :param display_name: Localized friendly display name of the dimension. + :type display_name: str + :param internal_name: Name of the dimension as it appears in MDM. + :type internal_name: str + :param to_be_exported_for_shoebox: A Boolean flag indicating whether this dimension should be + included for the shoebox export scenario. + :type to_be_exported_for_shoebox: bool + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'internal_name': {'key': 'internalName', 'type': 'str'}, + 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + internal_name: Optional[str] = None, + to_be_exported_for_shoebox: Optional[bool] = None, + **kwargs + ): + super(Dimension, self).__init__(**kwargs) + self.name = name + self.display_name = display_name + self.internal_name = internal_name + self.to_be_exported_for_shoebox = to_be_exported_for_shoebox + + +class ErrorResponse(msrest.serialization.Model): + """Error response indicating why the requested operation could not be performed. + + :param error: The error. + :type error: ~communication_service_management_client.models.ErrorResponseError + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + } + + def __init__( + self, + *, + error: Optional["ErrorResponseError"] = None, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class ErrorResponseError(msrest.serialization.Model): + """The error. + + :param code: Error code. + :type code: str + :param message: Error message indicating why the operation failed. + :type message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + super(ErrorResponseError, self).__init__(**kwargs) + self.code = code + self.message = message + + +class LinkedNotificationHub(msrest.serialization.Model): + """A notification hub that has been linked to the communication service. + + :param resource_id: The resource ID of the notification hub. + :type resource_id: str + """ + + _attribute_map = { + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + } + + def __init__( + self, + *, + resource_id: Optional[str] = None, + **kwargs + ): + super(LinkedNotificationHub, self).__init__(**kwargs) + self.resource_id = resource_id + + +class LinkNotificationHubParameters(msrest.serialization.Model): + """Description of an Azure Notification Hub to link to the communication service. + + All required parameters must be populated in order to send to Azure. + + :param resource_id: Required. The resource ID of the notification hub. + :type resource_id: str + :param connection_string: Required. Connection string for the notification hub. + :type connection_string: str + """ + + _validation = { + 'resource_id': {'required': True}, + 'connection_string': {'required': True}, + } + + _attribute_map = { + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'connection_string': {'key': 'connectionString', 'type': 'str'}, + } + + def __init__( + self, + *, + resource_id: str, + connection_string: str, + **kwargs + ): + super(LinkNotificationHubParameters, self).__init__(**kwargs) + self.resource_id = resource_id + self.connection_string = connection_string + + +class MetricSpecification(msrest.serialization.Model): + """Specifications of the Metrics for Azure Monitoring. + + :param name: Name of the metric. + :type name: str + :param display_name: Localized friendly display name of the metric. + :type display_name: str + :param display_description: Localized friendly description of the metric. + :type display_description: str + :param unit: The unit that makes sense for the metric. + :type unit: str + :param aggregation_type: The method for aggregating the metric. Possible values include: + "Average", "Minimum", "Maximum", "Total", "Count". + :type aggregation_type: str or ~communication_service_management_client.models.AggregationType + :param fill_gap_with_zero: Optional. If set to true, then zero will be returned for time + duration where no metric is emitted/published. + Ex. a metric that returns the number of times a particular error code was emitted. The error + code may not appear + often, instead of the RP publishing 0, Shoebox can auto fill in 0s for time periods where + nothing was emitted. + :type fill_gap_with_zero: str + :param category: The name of the metric category that the metric belongs to. A metric can only + belong to a single category. + :type category: str + :param dimensions: The dimensions of the metrics. + :type dimensions: list[~communication_service_management_client.models.Dimension] + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'display_description': {'key': 'displayDescription', 'type': 'str'}, + 'unit': {'key': 'unit', 'type': 'str'}, + 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, + 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'str'}, + 'category': {'key': 'category', 'type': 'str'}, + 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + display_description: Optional[str] = None, + unit: Optional[str] = None, + aggregation_type: Optional[Union[str, "AggregationType"]] = None, + fill_gap_with_zero: Optional[str] = None, + category: Optional[str] = None, + dimensions: Optional[List["Dimension"]] = None, + **kwargs + ): + super(MetricSpecification, self).__init__(**kwargs) + self.name = name + self.display_name = display_name + self.display_description = display_description + self.unit = unit + self.aggregation_type = aggregation_type + self.fill_gap_with_zero = fill_gap_with_zero + self.category = category + self.dimensions = dimensions + + +class NameAvailability(msrest.serialization.Model): + """Result of the request to check name availability. It contains a flag and possible reason of failure. + + :param name_available: Indicates whether the name is available or not. + :type name_available: bool + :param reason: The reason of the availability. Required if name is not available. + :type reason: str + :param message: The message of the operation. + :type message: str + """ + + _attribute_map = { + 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + name_available: Optional[bool] = None, + reason: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + super(NameAvailability, self).__init__(**kwargs) + self.name_available = name_available + self.reason = reason + self.message = message + + +class NameAvailabilityParameters(msrest.serialization.Model): + """Data POST-ed to the nameAvailability action. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. The resource type. Should be always + "Microsoft.Communication/CommunicationServices". + :type type: str + :param name: Required. The CommunicationService name to validate. e.g."my-CommunicationService- + name-here". + :type name: str + """ + + _validation = { + 'type': {'required': True}, + 'name': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + type: str, + name: str, + **kwargs + ): + super(NameAvailabilityParameters, self).__init__(**kwargs) + self.type = type + self.name = name + + +class Operation(msrest.serialization.Model): + """REST API operation supported by CommunicationService resource provider. + + :param name: Name of the operation with format: {provider}/{resource}/{operation}. + :type name: str + :param display: The object that describes the operation. + :type display: ~communication_service_management_client.models.OperationDisplay + :param origin: Optional. The intended executor of the operation; governs the display of the + operation in the RBAC UX and the audit logs UX. + :type origin: str + :param properties: Extra properties for the operation. + :type properties: ~communication_service_management_client.models.OperationProperties + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'OperationProperties'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + origin: Optional[str] = None, + properties: Optional["OperationProperties"] = None, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = name + self.display = display + self.origin = origin + self.properties = properties + + +class OperationDisplay(msrest.serialization.Model): + """The object that describes a operation. + + :param provider: Friendly name of the resource provider. + :type provider: str + :param resource: Resource type on which the operation is performed. + :type resource: str + :param operation: The localized friendly name for the operation. + :type operation: str + :param description: The localized friendly description for the operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationList(msrest.serialization.Model): + """Result of the request to list REST API operations. It contains a list of operations. + + :param value: List of operations supported by the resource provider. + :type value: list[~communication_service_management_client.models.Operation] + :param next_link: The URL the client should use to fetch the next page (per server side + paging). + It's null for now, added for future use. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OperationProperties(msrest.serialization.Model): + """Extra Operation properties. + + :param service_specification: The service specifications. + :type service_specification: + ~communication_service_management_client.models.ServiceSpecification + """ + + _attribute_map = { + 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, + } + + def __init__( + self, + *, + service_specification: Optional["ServiceSpecification"] = None, + **kwargs + ): + super(OperationProperties, self).__init__(**kwargs) + self.service_specification = service_specification + + +class OperationStatus(msrest.serialization.Model): + """The current status of an async operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified ID for the operation status. + :vartype id: str + :ivar status: Provisioning state of the resource. Possible values include: "Succeeded", + "Failed", "Canceled", "Creating", "Deleting", "Moving". + :vartype status: str or ~communication_service_management_client.models.Status + :ivar start_time: The start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the operation. + :vartype end_time: ~datetime.datetime + :ivar percent_complete: Percent of the operation that is complete. + :vartype percent_complete: float + :param error: The error. + :type error: ~communication_service_management_client.models.ErrorResponseError + """ + + _validation = { + 'id': {'readonly': True}, + 'status': {'readonly': True}, + 'start_time': {'readonly': True}, + 'end_time': {'readonly': True}, + 'percent_complete': {'readonly': True, 'maximum': 100, 'minimum': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, + 'percent_complete': {'key': 'percentComplete', 'type': 'float'}, + 'error': {'key': 'error.error', 'type': 'ErrorResponseError'}, + } + + def __init__( + self, + *, + error: Optional["ErrorResponseError"] = None, + **kwargs + ): + super(OperationStatus, self).__init__(**kwargs) + self.id = None + self.status = None + self.start_time = None + self.end_time = None + self.percent_complete = None + self.error = error + + +class RegenerateKeyParameters(msrest.serialization.Model): + """Parameters describes the request to regenerate access keys. + + :param key_type: The keyType to regenerate. Must be either 'primary' or 'secondary'(case- + insensitive). Possible values include: "Primary", "Secondary". + :type key_type: str or ~communication_service_management_client.models.KeyType + """ + + _attribute_map = { + 'key_type': {'key': 'keyType', 'type': 'str'}, + } + + def __init__( + self, + *, + key_type: Optional[Union[str, "KeyType"]] = None, + **kwargs + ): + super(RegenerateKeyParameters, self).__init__(**kwargs) + self.key_type = key_type + + +class ServiceSpecification(msrest.serialization.Model): + """An object that describes a specification. + + :param metric_specifications: Specifications of the Metrics for Azure Monitoring. + :type metric_specifications: + list[~communication_service_management_client.models.MetricSpecification] + """ + + _attribute_map = { + 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + } + + def __init__( + self, + *, + metric_specifications: Optional[List["MetricSpecification"]] = None, + **kwargs + ): + super(ServiceSpecification, self).__init__(**kwargs) + self.metric_specifications = metric_specifications diff --git a/src/communication/azext_communication/vendored_sdks/communication/operations/__init__.py b/src/communication/azext_communication/vendored_sdks/communication/operations/__init__.py new file mode 100644 index 00000000000..34e927cfe39 --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/operations/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operation_operations import OperationOperations +from ._communication_service_operations import CommunicationServiceOperations +from ._operation_statuses_operations import OperationStatusesOperations + +__all__ = [ + 'OperationOperations', + 'CommunicationServiceOperations', + 'OperationStatusesOperations', +] diff --git a/src/communication/azext_communication/vendored_sdks/communication/operations/_communication_service_operations.py b/src/communication/azext_communication/vendored_sdks/communication/operations/_communication_service_operations.py new file mode 100644 index 00000000000..d7d1ac8d71f --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/operations/_communication_service_operations.py @@ -0,0 +1,900 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class CommunicationServiceOperations(object): + """CommunicationServiceOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~communication_service_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def check_name_availability( + self, + type=None, # type: Optional[str] + name=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.NameAvailability" + """Check Name Availability. + + Checks that the CommunicationService name is valid and is not already in use. + + :param type: The resource type. Should be always + "Microsoft.Communication/CommunicationServices". + :type type: str + :param name: The CommunicationService name to validate. e.g."my-CommunicationService-name- + here". + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NameAvailability, or the result of cls(response) + :rtype: ~communication_service_management_client.models.NameAvailability + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.NameAvailability"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + name_availability_parameters = models.NameAvailabilityParameters(type=type, name=name) + api_version = "2020-08-20-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_name_availability.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if name_availability_parameters is not None: + body_content = self._serialize.body(name_availability_parameters, 'NameAvailabilityParameters') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('NameAvailability', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Communication/checkNameAvailability'} # type: ignore + + def link_notification_hub( + self, + resource_group_name, # type: str + communication_service_name, # type: str + resource_id=None, # type: Optional[str] + connection_string=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.LinkedNotificationHub" + """Link Notification Hub. + + Links an Azure Notification Hub to this communication service. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param communication_service_name: The name of the CommunicationService resource. + :type communication_service_name: str + :param resource_id: The resource ID of the notification hub. + :type resource_id: str + :param connection_string: Connection string for the notification hub. + :type connection_string: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LinkedNotificationHub, or the result of cls(response) + :rtype: ~communication_service_management_client.models.LinkedNotificationHub + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LinkedNotificationHub"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + link_notification_hub_parameters = models.LinkNotificationHubParameters(resource_id=resource_id, connection_string=connection_string) + api_version = "2020-08-20-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.link_notification_hub.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if link_notification_hub_parameters is not None: + body_content = self._serialize.body(link_notification_hub_parameters, 'LinkNotificationHubParameters') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LinkedNotificationHub', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + link_notification_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}/linkNotificationHub'} # type: ignore + + def list_by_subscription( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.CommunicationServiceResourceList"] + """List By Subscription. + + Handles requests to list all resources in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CommunicationServiceResourceList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~communication_service_management_client.models.CommunicationServiceResourceList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationServiceResourceList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-20-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('CommunicationServiceResourceList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Communication/communicationServices'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.CommunicationServiceResourceList"] + """List By Resource Group. + + Handles requests to list all resources in a resource group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CommunicationServiceResourceList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~communication_service_management_client.models.CommunicationServiceResourceList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationServiceResourceList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-20-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('CommunicationServiceResourceList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices'} # type: ignore + + def update( + self, + resource_group_name, # type: str + communication_service_name, # type: str + tags=None, # type: Optional[Dict[str, str]] + **kwargs # type: Any + ): + # type: (...) -> "models.CommunicationServiceResource" + """Update. + + Operation to update an existing CommunicationService. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param communication_service_name: The name of the CommunicationService resource. + :type communication_service_name: str + :param tags: Tags of the service which is a list of key value pairs that describe the resource. + :type tags: dict[str, str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunicationServiceResource, or the result of cls(response) + :rtype: ~communication_service_management_client.models.CommunicationServiceResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationServiceResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + parameters = models.TaggedResource(tags=tags) + api_version = "2020-08-20-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if parameters is not None: + body_content = self._serialize.body(parameters, 'TaggedResource') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CommunicationServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}'} # type: ignore + + def get( + self, + resource_group_name, # type: str + communication_service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.CommunicationServiceResource" + """Get. + + Get the CommunicationService and its properties. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param communication_service_name: The name of the CommunicationService resource. + :type communication_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunicationServiceResource, or the result of cls(response) + :rtype: ~communication_service_management_client.models.CommunicationServiceResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationServiceResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-20-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CommunicationServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}'} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name, # type: str + communication_service_name, # type: str + location=None, # type: Optional[str] + tags=None, # type: Optional[Dict[str, str]] + data_location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.CommunicationServiceResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationServiceResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + parameters = models.CommunicationServiceResource(location=location, tags=tags, data_location=data_location) + api_version = "2020-08-20-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if parameters is not None: + body_content = self._serialize.body(parameters, 'CommunicationServiceResource') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('CommunicationServiceResource', pipeline_response) + + if response.status_code == 201: + response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('CommunicationServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + communication_service_name, # type: str + location=None, # type: Optional[str] + tags=None, # type: Optional[Dict[str, str]] + data_location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.CommunicationServiceResource"] + """Create Or Update. + + Create a new CommunicationService or update an existing CommunicationService. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param communication_service_name: The name of the CommunicationService resource. + :type communication_service_name: str + :param location: The Azure location where the CommunicationService is running. + :type location: str + :param tags: Tags of the service which is a list of key value pairs that describe the resource. + :type tags: dict[str, str] + :param data_location: The location where the communication service stores its data at rest. + :type data_location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either CommunicationServiceResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~communication_service_management_client.models.CommunicationServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationServiceResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + communication_service_name=communication_service_name, + location=location, + tags=tags, + data_location=data_location, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('CommunicationServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name, # type: str + communication_service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-20-preview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + communication_service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] + """Delete. + + Operation to delete a CommunicationService. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param communication_service_name: The name of the CommunicationService resource. + :type communication_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + communication_service_name=communication_service_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}'} # type: ignore + + def list_key( + self, + resource_group_name, # type: str + communication_service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.CommunicationServiceKeys" + """List Keys. + + Get the access keys of the CommunicationService resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param communication_service_name: The name of the CommunicationService resource. + :type communication_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunicationServiceKeys, or the result of cls(response) + :rtype: ~communication_service_management_client.models.CommunicationServiceKeys + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationServiceKeys"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-20-preview" + accept = "application/json" + + # Construct URL + url = self.list_key.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CommunicationServiceKeys', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}/listKeys'} # type: ignore + + def regenerate_key( + self, + resource_group_name, # type: str + communication_service_name, # type: str + key_type=None, # type: Optional[Union[str, "models.KeyType"]] + **kwargs # type: Any + ): + # type: (...) -> "models.CommunicationServiceKeys" + """Regenerate Key. + + Regenerate CommunicationService access key. PrimaryKey and SecondaryKey cannot be regenerated + at the same time. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param communication_service_name: The name of the CommunicationService resource. + :type communication_service_name: str + :param key_type: The keyType to regenerate. Must be either 'primary' or 'secondary'(case- + insensitive). + :type key_type: str or ~communication_service_management_client.models.KeyType + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CommunicationServiceKeys, or the result of cls(response) + :rtype: ~communication_service_management_client.models.CommunicationServiceKeys + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CommunicationServiceKeys"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + parameters = models.RegenerateKeyParameters(key_type=key_type) + api_version = "2020-08-20-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.regenerate_key.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'communicationServiceName': self._serialize.url("communication_service_name", communication_service_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if parameters is not None: + body_content = self._serialize.body(parameters, 'RegenerateKeyParameters') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('CommunicationServiceKeys', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('CommunicationServiceKeys', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}/regenerateKey'} # type: ignore diff --git a/src/communication/azext_communication/vendored_sdks/communication/operations/_operation_operations.py b/src/communication/azext_communication/vendored_sdks/communication/operations/_operation_operations.py new file mode 100644 index 00000000000..060096b89f9 --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/operations/_operation_operations.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations(object): + """OperationOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~communication_service_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationList"] + """List Operations. + + Lists all of the available REST API operations of the Microsoft.Communication provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~communication_service_management_client.models.OperationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-20-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Communication/operations'} # type: ignore diff --git a/src/communication/azext_communication/vendored_sdks/communication/operations/_operation_statuses_operations.py b/src/communication/azext_communication/vendored_sdks/communication/operations/_operation_statuses_operations.py new file mode 100644 index 00000000000..9e3f99b57d1 --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/operations/_operation_statuses_operations.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class OperationStatusesOperations(object): + """OperationStatusesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~communication_service_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + location, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.OperationStatus" + """Get Operation Status. + + Gets the current status of an async operation. + + :param location: The Azure region. + :type location: str + :param operation_id: The ID of an ongoing async operation. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatus, or the result of cls(response) + :rtype: ~communication_service_management_client.models.OperationStatus + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationStatus"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-08-20-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'location': self._serialize.url("location", location, 'str'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('OperationStatus', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Communication/locations/{location}/operationStatuses/{operationId}'} # type: ignore diff --git a/src/communication/azext_communication/vendored_sdks/communication/py.typed b/src/communication/azext_communication/vendored_sdks/communication/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/communication/azext_communication/vendored_sdks/communication/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/communication/report.md b/src/communication/report.md new file mode 100644 index 00000000000..01ffa892436 --- /dev/null +++ b/src/communication/report.md @@ -0,0 +1,166 @@ +# Azure CLI Module Creation Report + +## EXTENSION +|CLI Extension|Command Groups| +|---------|------------| +|az communication|[groups](#CommandGroups) + +## GROUPS +### Command groups in `az communication` extension +|CLI Command Group|Group Swagger name|Commands| +|---------|------------|--------| +|az communication service|CommunicationService|[commands](#CommandsInCommunicationService)| +|az communication status|OperationStatuses|[commands](#CommandsInOperationStatuses)| + +## COMMANDS +### Commands in `az communication service` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az communication service list](#CommunicationServiceListByResourceGroup)|ListByResourceGroup|[Parameters](#ParametersCommunicationServiceListByResourceGroup)|[Example](#ExamplesCommunicationServiceListByResourceGroup)| +|[az communication service list](#CommunicationServiceListBySubscription)|ListBySubscription|[Parameters](#ParametersCommunicationServiceListBySubscription)|[Example](#ExamplesCommunicationServiceListBySubscription)| +|[az communication service show](#CommunicationServiceGet)|Get|[Parameters](#ParametersCommunicationServiceGet)|[Example](#ExamplesCommunicationServiceGet)| +|[az communication service create](#CommunicationServiceCreateOrUpdate#Create)|CreateOrUpdate#Create|[Parameters](#ParametersCommunicationServiceCreateOrUpdate#Create)|[Example](#ExamplesCommunicationServiceCreateOrUpdate#Create)| +|[az communication service update](#CommunicationServiceUpdate)|Update|[Parameters](#ParametersCommunicationServiceUpdate)|[Example](#ExamplesCommunicationServiceUpdate)| +|[az communication service delete](#CommunicationServiceDelete)|Delete|[Parameters](#ParametersCommunicationServiceDelete)|[Example](#ExamplesCommunicationServiceDelete)| +|[az communication service link-notification-hub](#CommunicationServiceLinkNotificationHub)|LinkNotificationHub|[Parameters](#ParametersCommunicationServiceLinkNotificationHub)|[Example](#ExamplesCommunicationServiceLinkNotificationHub)| +|[az communication service list-key](#CommunicationServiceListKeys)|ListKeys|[Parameters](#ParametersCommunicationServiceListKeys)|[Example](#ExamplesCommunicationServiceListKeys)| +|[az communication service regenerate-key](#CommunicationServiceRegenerateKey)|RegenerateKey|[Parameters](#ParametersCommunicationServiceRegenerateKey)|[Example](#ExamplesCommunicationServiceRegenerateKey)| + +### Commands in `az communication status` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az communication status show](#OperationStatusesGet)|Get|[Parameters](#ParametersOperationStatusesGet)|[Example](#ExamplesOperationStatusesGet)| + + +## COMMAND DETAILS + +### group `az communication service` +#### Command `az communication service list` + +##### Example +``` +az communication service list --resource-group "MyResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.|resource_group_name|resourceGroupName| + +#### Command `az communication service list` + +##### Example +``` +az communication service list +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az communication service show` + +##### Example +``` +az communication service show --name "MyCommunicationResource" --resource-group "MyResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.|resource_group_name|resourceGroupName| +|**--name**|string|The name of the CommunicationService resource.|name|communicationServiceName| + +#### Command `az communication service create` + +##### Example +``` +az communication service create --name "MyCommunicationResource" --location "Global" --data-location "United States" \ +--resource-group "MyResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.|resource_group_name|resourceGroupName| +|**--name**|string|The name of the CommunicationService resource.|name|communicationServiceName| +|**--location**|string|The Azure location where the CommunicationService is running.|location|location| +|**--tags**|dictionary|Tags of the service which is a list of key value pairs that describe the resource.|tags|tags| +|**--data-location**|string|The location where the communication service stores its data at rest.|data_location|dataLocation| + +#### Command `az communication service update` + +##### Example +``` +az communication service update --name "MyCommunicationResource" --tags newTag="newVal" --resource-group \ +"MyResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.|resource_group_name|resourceGroupName| +|**--name**|string|The name of the CommunicationService resource.|name|communicationServiceName| +|**--tags**|dictionary|Tags of the service which is a list of key value pairs that describe the resource.|tags|tags| + +#### Command `az communication service delete` + +##### Example +``` +az communication service delete --name "MyCommunicationResource" --resource-group "MyResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.|resource_group_name|resourceGroupName| +|**--name**|string|The name of the CommunicationService resource.|name|communicationServiceName| + +#### Command `az communication service link-notification-hub` + +##### Example +``` +az communication service link-notification-hub --name "MyCommunicationResource" --connection-string \ +"Endpoint=sb://MyNamespace.servicebus.windows.net/;SharedAccessKey=abcd1234" --resource-id \ +"/subscriptions/12345/resourceGroups/MyOtherResourceGroup/providers/Microsoft.NotificationHubs/namespaces/MyNamespace/n\ +otificationHubs/MyHub" --resource-group "MyResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.|resource_group_name|resourceGroupName| +|**--name**|string|The name of the CommunicationService resource.|name|communicationServiceName| +|**--resource-id**|string|The resource ID of the notification hub|resource_id|resourceId| +|**--connection-string**|string|Connection string for the notification hub|connection_string|connectionString| + +#### Command `az communication service list-key` + +##### Example +``` +az communication service list-key --name "MyCommunicationResource" --resource-group "MyResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.|resource_group_name|resourceGroupName| +|**--name**|string|The name of the CommunicationService resource.|name|communicationServiceName| + +#### Command `az communication service regenerate-key` + +##### Example +``` +az communication service regenerate-key --name "MyCommunicationResource" --key-type "Primary" --resource-group \ +"MyResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.|resource_group_name|resourceGroupName| +|**--name**|string|The name of the CommunicationService resource.|name|communicationServiceName| +|**--key-type**|sealed-choice|The keyType to regenerate. Must be either 'primary' or 'secondary'(case-insensitive).|key_type|keyType| + +### group `az communication status` +#### Command `az communication status show` + +##### Example +``` +az communication status show --operation-id "db5f291f-284d-46e9-9152-d5c83f7c14b8" --location "westus2" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--location**|string|The Azure region|location|location| +|**--operation-id**|string|The ID of an ongoing async operation|operation_id|operationId| diff --git a/src/communication/setup.cfg b/src/communication/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/communication/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/communication/setup.py b/src/communication/setup.py new file mode 100644 index 00000000000..3b81fdb71de --- /dev/null +++ b/src/communication/setup.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +from codecs import open +from setuptools import setup, find_packages + +# HISTORY.rst entry. +VERSION = '0.1.0' +try: + from azext_communication.manual.version import VERSION +except ImportError: + pass + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', +] + +DEPENDENCIES = [] + +try: + from azext_communication.manual.dependency import DEPENDENCIES +except ImportError: + pass + +with open('README.md', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='communication', + version=VERSION, + description='Microsoft Azure Command-Line Tools CommunicationServiceManagementClient Extension', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/master/src/communication', + long_description=README + '\n\n' + HISTORY, + license='MIT', + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={'azext_communication': ['azext_metadata.json']}, +)