From 90c3f202c1af612f276dab4ab0f897488106574e Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 7 Dec 2020 09:40:53 +0000 Subject: [PATCH] CodeGen from PR 11939 in Azure/azure-rest-api-specs [Hub Generated] Public private branch 'credscan-fix' (#11939) * Fix credscan * Fix more credentials --- .../azure/mgmt/communication/__init__.py | 19 + ...communication_service_management_client.py | 61 ++ .../mgmt/communication/_configuration.py | 50 ++ .../mgmt/communication/models/__init__.py | 87 ++ ...ication_service_management_client_enums.py | 50 ++ .../mgmt/communication/models/_models.py | 592 ++++++++++++ .../mgmt/communication/models/_models_py3.py | 592 ++++++++++++ .../communication/models/_paged_models.py | 40 + .../mgmt/communication/operations/__init__.py | 20 + .../_communication_service_operations.py | 840 ++++++++++++++++++ .../_operation_statuses_operations.py | 100 +++ .../communication/operations/_operations.py | 103 +++ .../azure/mgmt/communication/version.py | 13 + 13 files changed, 2567 insertions(+) create mode 100644 sdk/communication/azure-mgmt-communication/azure/mgmt/communication/__init__.py create mode 100644 sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_communication_service_management_client.py create mode 100644 sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_configuration.py create mode 100644 sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/__init__.py create mode 100644 sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_communication_service_management_client_enums.py create mode 100644 sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_models.py create mode 100644 sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_models_py3.py create mode 100644 sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_paged_models.py create mode 100644 sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/__init__.py create mode 100644 sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_communication_service_operations.py create mode 100644 sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_operation_statuses_operations.py create mode 100644 sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_operations.py create mode 100644 sdk/communication/azure-mgmt-communication/azure/mgmt/communication/version.py diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/__init__.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/__init__.py new file mode 100644 index 000000000000..4dc1735fea3c --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/__init__.py @@ -0,0 +1,19 @@ +# 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 ._configuration import CommunicationServiceManagementClientConfiguration +from ._communication_service_management_client import CommunicationServiceManagementClient +__all__ = ['CommunicationServiceManagementClient', 'CommunicationServiceManagementClientConfiguration'] + +from .version import VERSION + +__version__ = VERSION + diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_communication_service_management_client.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_communication_service_management_client.py new file mode 100644 index 000000000000..67fe360ee801 --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_communication_service_management_client.py @@ -0,0 +1,61 @@ +# 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 msrest.service_client import SDKClient +from msrest import Serializer, Deserializer + +from ._configuration import CommunicationServiceManagementClientConfiguration +from .operations import Operations +from .operations import CommunicationServiceOperations +from .operations import OperationStatusesOperations +from . import models + + +class CommunicationServiceManagementClient(SDKClient): + """REST API for Azure Communication Services + + :ivar config: Configuration for client. + :vartype config: CommunicationServiceManagementClientConfiguration + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.communication.operations.Operations + :ivar communication_service: CommunicationService operations + :vartype communication_service: azure.mgmt.communication.operations.CommunicationServiceOperations + :ivar operation_statuses: OperationStatuses operations + :vartype operation_statuses: azure.mgmt.communication.operations.OperationStatusesOperations + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: Gets subscription ID which uniquely identifies the + Microsoft Azure subscription. The subscription ID forms part of the URI + for every service call. + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + self.config = CommunicationServiceManagementClientConfiguration(credentials, subscription_id, base_url) + super(CommunicationServiceManagementClient, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '2020-08-20-preview' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + 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) diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_configuration.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_configuration.py new file mode 100644 index 000000000000..d758a31ecc86 --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/_configuration.py @@ -0,0 +1,50 @@ +# 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 msrestazure import AzureConfiguration + +from .version import VERSION + + +class CommunicationServiceManagementClientConfiguration(AzureConfiguration): + """Configuration for CommunicationServiceManagementClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: Gets subscription ID which uniquely identifies the + Microsoft Azure subscription. The subscription ID forms part of the URI + for every service call. + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + if not base_url: + base_url = 'https://management.azure.com' + + super(CommunicationServiceManagementClientConfiguration, self).__init__(base_url) + + # Starting Autorest.Python 4.0.64, make connection pool activated by default + self.keep_alive = True + + self.add_user_agent('azure-mgmt-communication/{}'.format(VERSION)) + self.add_user_agent('Azure-SDK-For-Python') + + self.credentials = credentials + self.subscription_id = subscription_id diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/__init__.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/__init__.py new file mode 100644 index 000000000000..34b1e53a89de --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/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 Dimension + from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import ErrorResponseError + from ._models_py3 import LinkedNotificationHub + from ._models_py3 import LinkNotificationHubParameters + 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 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 + from ._models import CommunicationServiceResource + from ._models import Dimension + from ._models import ErrorResponse, ErrorResponseException + from ._models import ErrorResponseError + from ._models import LinkedNotificationHub + from ._models import LinkNotificationHubParameters + from ._models import LocationResource + from ._models import MetricSpecification + from ._models import NameAvailability + from ._models import NameAvailabilityParameters + from ._models import Operation + from ._models import OperationDisplay + from ._models import OperationProperties + from ._models import OperationStatus + from ._models import RegenerateKeyParameters + from ._models import Resource + from ._models import ServiceSpecification + from ._models import TaggedResource +from ._paged_models import CommunicationServiceResourcePaged +from ._paged_models import OperationPaged +from ._communication_service_management_client_enums import ( + AggregationType, + Status, + ProvisioningState, + KeyType, +) + +__all__ = [ + 'CommunicationServiceKeys', + 'CommunicationServiceResource', + 'Dimension', + 'ErrorResponse', 'ErrorResponseException', + 'ErrorResponseError', + 'LinkedNotificationHub', + 'LinkNotificationHubParameters', + 'LocationResource', + 'MetricSpecification', + 'NameAvailability', + 'NameAvailabilityParameters', + 'Operation', + 'OperationDisplay', + 'OperationProperties', + 'OperationStatus', + 'RegenerateKeyParameters', + 'Resource', + 'ServiceSpecification', + 'TaggedResource', + 'OperationPaged', + 'CommunicationServiceResourcePaged', + 'AggregationType', + 'Status', + 'ProvisioningState', + 'KeyType', +] diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_communication_service_management_client_enums.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_communication_service_management_client_enums.py new file mode 100644 index 000000000000..f2f73b89f8b9 --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_communication_service_management_client_enums.py @@ -0,0 +1,50 @@ +# 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 + + +class AggregationType(str, Enum): + + average = "Average" + minimum = "Minimum" + maximum = "Maximum" + total = "Total" + count = "Count" + + +class Status(str, Enum): + + succeeded = "Succeeded" + failed = "Failed" + canceled = "Canceled" + creating = "Creating" + deleting = "Deleting" + moving = "Moving" + + +class ProvisioningState(str, Enum): + + unknown = "Unknown" + succeeded = "Succeeded" + failed = "Failed" + canceled = "Canceled" + running = "Running" + creating = "Creating" + updating = "Updating" + deleting = "Deleting" + moving = "Moving" + + +class KeyType(str, Enum): + + primary = "Primary" + secondary = "Secondary" diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_models.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_models.py new file mode 100644 index 000000000000..deb295407b2a --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_models.py @@ -0,0 +1,592 @@ +# 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 msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class CloudError(Model): + """CloudError. + """ + + _attribute_map = { + } + + +class CommunicationServiceKeys(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 CommunicationServiceResource(Model): + """A class representing a CommunicationService resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :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 + :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] + :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 + ~azure.mgmt.communication.models.ProvisioningState + :ivar host_name: FQDN of the CommunicationService instance. + :vartype host_name: str + :param data_location: Required. 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}, + 'data_location': {'required': True}, + 'notification_hub_id': {'readonly': True}, + 'version': {'readonly': True}, + 'immutable_resource_id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', '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.id = None + self.name = None + self.type = None + self.location = kwargs.get('location', None) + self.tags = kwargs.get('tags', 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 Dimension(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(Model): + """Error response indicating why the requested operation could not be + performed. + + :param error: The error + :type error: ~azure.mgmt.communication.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 ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + + +class ErrorResponseError(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(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(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.get('resource_id', None) + self.connection_string = kwargs.get('connection_string', None) + + +class LocationResource(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 MetricSpecification(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 + ~azure.mgmt.communication.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[~azure.mgmt.communication.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(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(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.get('type', None) + self.name = kwargs.get('name', None) + + +class Operation(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: ~azure.mgmt.communication.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: ~azure.mgmt.communication.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(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 OperationProperties(Model): + """Extra Operation properties. + + :param service_specification: The service specifications. + :type service_specification: + ~azure.mgmt.communication.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(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 ~azure.mgmt.communication.models.Status + :ivar start_time: The start time of the operation + :vartype start_time: datetime + :ivar end_time: The end time of the operation + :vartype end_time: datetime + :ivar percent_complete: Percent of the operation that is complete + :vartype percent_complete: float + :param error: The error + :type error: ~azure.mgmt.communication.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(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 ~azure.mgmt.communication.models.KeyType + """ + + _attribute_map = { + 'key_type': {'key': 'keyType', 'type': 'KeyType'}, + } + + def __init__(self, **kwargs): + super(RegenerateKeyParameters, self).__init__(**kwargs) + self.key_type = kwargs.get('key_type', None) + + +class Resource(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 ServiceSpecification(Model): + """An object that describes a specification. + + :param metric_specifications: Specifications of the Metrics for Azure + Monitoring. + :type metric_specifications: + list[~azure.mgmt.communication.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) + + +class TaggedResource(Model): + """An ARM resource with that can accept tags. + + :param 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) diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_models_py3.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_models_py3.py new file mode 100644 index 000000000000..e327b840109b --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_models_py3.py @@ -0,0 +1,592 @@ +# 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 msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class CloudError(Model): + """CloudError. + """ + + _attribute_map = { + } + + +class CommunicationServiceKeys(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: str=None, secondary_key: str=None, primary_connection_string: str=None, secondary_connection_string: str=None, **kwargs) -> None: + 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 CommunicationServiceResource(Model): + """A class representing a CommunicationService resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :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 + :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] + :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 + ~azure.mgmt.communication.models.ProvisioningState + :ivar host_name: FQDN of the CommunicationService instance. + :vartype host_name: str + :param data_location: Required. 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}, + 'data_location': {'required': True}, + 'notification_hub_id': {'readonly': True}, + 'version': {'readonly': True}, + 'immutable_resource_id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', '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, *, data_location: str, location: str=None, tags=None, **kwargs) -> None: + super(CommunicationServiceResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + 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 Dimension(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: str=None, display_name: str=None, internal_name: str=None, to_be_exported_for_shoebox: bool=None, **kwargs) -> None: + 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(Model): + """Error response indicating why the requested operation could not be + performed. + + :param error: The error + :type error: ~azure.mgmt.communication.models.ErrorResponseError + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponseError'}, + } + + def __init__(self, *, error=None, **kwargs) -> None: + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + + +class ErrorResponseError(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: str=None, message: str=None, **kwargs) -> None: + super(ErrorResponseError, self).__init__(**kwargs) + self.code = code + self.message = message + + +class LinkedNotificationHub(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: str=None, **kwargs) -> None: + super(LinkedNotificationHub, self).__init__(**kwargs) + self.resource_id = resource_id + + +class LinkNotificationHubParameters(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) -> None: + super(LinkNotificationHubParameters, self).__init__(**kwargs) + self.resource_id = resource_id + self.connection_string = connection_string + + +class LocationResource(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: str=None, **kwargs) -> None: + super(LocationResource, self).__init__(**kwargs) + self.location = location + + +class MetricSpecification(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 + ~azure.mgmt.communication.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[~azure.mgmt.communication.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: str=None, display_name: str=None, display_description: str=None, unit: str=None, aggregation_type=None, fill_gap_with_zero: str=None, category: str=None, dimensions=None, **kwargs) -> None: + 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(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: bool=None, reason: str=None, message: str=None, **kwargs) -> None: + super(NameAvailability, self).__init__(**kwargs) + self.name_available = name_available + self.reason = reason + self.message = message + + +class NameAvailabilityParameters(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) -> None: + super(NameAvailabilityParameters, self).__init__(**kwargs) + self.type = type + self.name = name + + +class Operation(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: ~azure.mgmt.communication.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: ~azure.mgmt.communication.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: str=None, display=None, origin: str=None, properties=None, **kwargs) -> None: + super(Operation, self).__init__(**kwargs) + self.name = name + self.display = display + self.origin = origin + self.properties = properties + + +class OperationDisplay(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: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationProperties(Model): + """Extra Operation properties. + + :param service_specification: The service specifications. + :type service_specification: + ~azure.mgmt.communication.models.ServiceSpecification + """ + + _attribute_map = { + 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, + } + + def __init__(self, *, service_specification=None, **kwargs) -> None: + super(OperationProperties, self).__init__(**kwargs) + self.service_specification = service_specification + + +class OperationStatus(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 ~azure.mgmt.communication.models.Status + :ivar start_time: The start time of the operation + :vartype start_time: datetime + :ivar end_time: The end time of the operation + :vartype end_time: datetime + :ivar percent_complete: Percent of the operation that is complete + :vartype percent_complete: float + :param error: The error + :type error: ~azure.mgmt.communication.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=None, **kwargs) -> None: + 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(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 ~azure.mgmt.communication.models.KeyType + """ + + _attribute_map = { + 'key_type': {'key': 'keyType', 'type': 'KeyType'}, + } + + def __init__(self, *, key_type=None, **kwargs) -> None: + super(RegenerateKeyParameters, self).__init__(**kwargs) + self.key_type = key_type + + +class Resource(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) -> None: + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ServiceSpecification(Model): + """An object that describes a specification. + + :param metric_specifications: Specifications of the Metrics for Azure + Monitoring. + :type metric_specifications: + list[~azure.mgmt.communication.models.MetricSpecification] + """ + + _attribute_map = { + 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + } + + def __init__(self, *, metric_specifications=None, **kwargs) -> None: + super(ServiceSpecification, self).__init__(**kwargs) + self.metric_specifications = metric_specifications + + +class TaggedResource(Model): + """An ARM resource with that can accept tags. + + :param 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=None, **kwargs) -> None: + super(TaggedResource, self).__init__(**kwargs) + self.tags = tags diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_paged_models.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_paged_models.py new file mode 100644 index 000000000000..1215d0ffff42 --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/models/_paged_models.py @@ -0,0 +1,40 @@ +# 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 msrest.paging import Paged + + +class OperationPaged(Paged): + """ + A paging container for iterating over a list of :class:`Operation ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[Operation]'} + } + + def __init__(self, *args, **kwargs): + + super(OperationPaged, self).__init__(*args, **kwargs) +class CommunicationServiceResourcePaged(Paged): + """ + A paging container for iterating over a list of :class:`CommunicationServiceResource ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[CommunicationServiceResource]'} + } + + def __init__(self, *args, **kwargs): + + super(CommunicationServiceResourcePaged, self).__init__(*args, **kwargs) diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/__init__.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/__init__.py new file mode 100644 index 000000000000..8fa1db7d26bb --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/__init__.py @@ -0,0 +1,20 @@ +# 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 ._operations import Operations +from ._communication_service_operations import CommunicationServiceOperations +from ._operation_statuses_operations import OperationStatusesOperations + +__all__ = [ + 'Operations', + 'CommunicationServiceOperations', + 'OperationStatusesOperations', +] diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_communication_service_operations.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_communication_service_operations.py new file mode 100644 index 000000000000..1e7343502c86 --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_communication_service_operations.py @@ -0,0 +1,840 @@ +# 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 uuid +from msrest.pipeline import ClientRawResponse +from msrest.polling import LROPoller, NoPolling +from msrestazure.polling.arm_polling import ARMPolling + +from .. import models + + +class CommunicationServiceOperations(object): + """CommunicationServiceOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: Client Api Version. Constant value: "2020-08-20-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2020-08-20-preview" + + self.config = config + + def check_name_availability( + self, type, name, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: NameAvailability or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.communication.models.NameAvailability or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + name_availability_parameters = None + if type is not None or name is not None: + name_availability_parameters = models.NameAvailabilityParameters(type=type, name=name) + + # Construct URL + url = self.check_name_availability.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + if name_availability_parameters is not None: + body_content = self._serialize.body(name_availability_parameters, 'NameAvailabilityParameters') + else: + body_content = None + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('NameAvailability', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Communication/checkNameAvailability'} + + def link_notification_hub( + self, resource_group_name, communication_service_name, resource_id, connection_string, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: LinkedNotificationHub or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.communication.models.LinkedNotificationHub or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + link_notification_hub_parameters = None + if resource_id is not None or connection_string is not None: + link_notification_hub_parameters = models.LinkNotificationHubParameters(resource_id=resource_id, connection_string=connection_string) + + # Construct URL + url = self.link_notification_hub.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + '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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + if link_notification_hub_parameters is not None: + body_content = self._serialize.body(link_notification_hub_parameters, 'LinkNotificationHubParameters') + else: + body_content = None + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('LinkedNotificationHub', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + link_notification_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}/linkNotificationHub'} + + def list_by_subscription( + self, custom_headers=None, raw=False, **operation_config): + """List By Subscription. + + Handles requests to list all resources in a subscription. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of CommunicationServiceResource + :rtype: + ~azure.mgmt.communication.models.CommunicationServiceResourcePaged[~azure.mgmt.communication.models.CommunicationServiceResource] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.CommunicationServiceResourcePaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Communication/communicationServices'} + + def list_by_resource_group( + self, resource_group_name, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of CommunicationServiceResource + :rtype: + ~azure.mgmt.communication.models.CommunicationServiceResourcePaged[~azure.mgmt.communication.models.CommunicationServiceResource] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.CommunicationServiceResourcePaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices'} + + def update( + self, resource_group_name, communication_service_name, tags=None, custom_headers=None, raw=False, **operation_config): + """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] + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: CommunicationServiceResource or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.communication.models.CommunicationServiceResource + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + parameters = None + if tags is not None: + parameters = models.TaggedResource(tags=tags) + + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + '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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + if parameters is not None: + body_content = self._serialize.body(parameters, 'TaggedResource') + else: + body_content = None + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('CommunicationServiceResource', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}'} + + def get( + self, resource_group_name, communication_service_name, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: CommunicationServiceResource or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.communication.models.CommunicationServiceResource + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + '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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('CommunicationServiceResource', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}'} + + + def _create_or_update_initial( + self, resource_group_name, communication_service_name, parameters=None, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.create_or_update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + '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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + if parameters is not None: + body_content = self._serialize.body(parameters, 'CommunicationServiceResource') + else: + body_content = None + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 201]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + header_dict = {} + + if response.status_code == 200: + deserialized = self._deserialize('CommunicationServiceResource', response) + header_dict = { + 'Azure-AsyncOperation': 'str', + } + if response.status_code == 201: + deserialized = self._deserialize('CommunicationServiceResource', response) + header_dict = { + 'Azure-AsyncOperation': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + + def create_or_update( + self, resource_group_name, communication_service_name, parameters=None, custom_headers=None, raw=False, polling=True, **operation_config): + """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 parameters: Parameters for the create or update operation + :type parameters: + ~azure.mgmt.communication.models.CommunicationServiceResource + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns + CommunicationServiceResource or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.communication.models.CommunicationServiceResource] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.communication.models.CommunicationServiceResource]] + :raises: + :class:`ErrorResponseException` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + communication_service_name=communication_service_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + header_dict = { + 'Azure-AsyncOperation': 'str', + } + deserialized = self._deserialize('CommunicationServiceResource', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}'} + + + def _delete_initial( + self, resource_group_name, communication_service_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + '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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202, 204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + header_dict = { + 'location': 'str', + } + client_raw_response.add_headers(header_dict) + return client_raw_response + + def delete( + self, resource_group_name, communication_service_name, custom_headers=None, raw=False, polling=True, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns None or + ClientRawResponse if raw==True + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] + :raises: + :class:`ErrorResponseException` + """ + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + communication_service_name=communication_service_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + if raw: + client_raw_response = ClientRawResponse(None, response) + client_raw_response.add_headers({ + 'location': 'str', + }) + return client_raw_response + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}'} + + def list_keys( + self, resource_group_name, communication_service_name, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: CommunicationServiceKeys or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.communication.models.CommunicationServiceKeys or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.list_keys.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + '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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('CommunicationServiceKeys', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}/listKeys'} + + def regenerate_key( + self, resource_group_name, communication_service_name, key_type=None, custom_headers=None, raw=False, **operation_config): + """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). Possible values include: 'Primary', + 'Secondary' + :type key_type: str or ~azure.mgmt.communication.models.KeyType + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: CommunicationServiceKeys or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.communication.models.CommunicationServiceKeys or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + parameters = None + if key_type is not None: + parameters = models.RegenerateKeyParameters(key_type=key_type) + + # Construct URL + url = self.regenerate_key.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + '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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + if parameters is not None: + body_content = self._serialize.body(parameters, 'RegenerateKeyParameters') + else: + body_content = None + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 201]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('CommunicationServiceKeys', response) + if response.status_code == 201: + deserialized = self._deserialize('CommunicationServiceKeys', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}/regenerateKey'} diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_operation_statuses_operations.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_operation_statuses_operations.py new file mode 100644 index 000000000000..0bf9a6ff2ee6 --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_operation_statuses_operations.py @@ -0,0 +1,100 @@ +# 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 uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class OperationStatusesOperations(object): + """OperationStatusesOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: Client Api Version. Constant value: "2020-08-20-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2020-08-20-preview" + + self.config = config + + def get( + self, location, operation_id, custom_headers=None, raw=False, **operation_config): + """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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: OperationStatus or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.communication.models.OperationStatus or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get.metadata['url'] + 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 = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('OperationStatus', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Communication/locations/{location}/operationStatuses/{operationId}'} diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_operations.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_operations.py new file mode 100644 index 000000000000..33ac7e8d6c29 --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/operations/_operations.py @@ -0,0 +1,103 @@ +# 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 uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class Operations(object): + """Operations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: Client Api Version. Constant value: "2020-08-20-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2020-08-20-preview" + + self.config = config + + def list( + self, custom_headers=None, raw=False, **operation_config): + """List Operations. + + Lists all of the available REST API operations of the + Microsoft.Communication provider. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of Operation + :rtype: + ~azure.mgmt.communication.models.OperationPaged[~azure.mgmt.communication.models.Operation] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list.metadata = {'url': '/providers/Microsoft.Communication/operations'} diff --git a/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/version.py b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/version.py new file mode 100644 index 000000000000..dd95c38f3058 --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/azure/mgmt/communication/version.py @@ -0,0 +1,13 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0rc1" +