diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_subscription_client.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_subscription_client.py index 5974551c34a8..50368efac6d7 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_subscription_client.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/_subscription_client.py @@ -17,6 +17,7 @@ from .operations import TenantsOperations from .operations import SubscriptionOperations from .operations import Operations +from .operations import AliasOperations from . import models @@ -34,6 +35,8 @@ class SubscriptionClient(SDKClient): :vartype subscription: azure.mgmt.subscription.operations.SubscriptionOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.subscription.operations.Operations + :ivar alias: Alias operations + :vartype alias: azure.mgmt.subscription.operations.AliasOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -59,3 +62,5 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.operations = Operations( self._client, self.config, self._serialize, self._deserialize) + self.alias = AliasOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models.py index 95f8b8e0b91d..c012e9f35208 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models.py @@ -275,11 +275,17 @@ def __init__(self, **kwargs): class PutAliasRequest(Model): """The parameters required to create a new subscription. - :param properties: Put alias request properties. + All required parameters must be populated in order to send to Azure. + + :param properties: Required. Put alias request properties. :type properties: ~azure.mgmt.subscription.models.PutAliasRequestProperties """ + _validation = { + 'properties': {'required': True}, + } + _attribute_map = { 'properties': {'key': 'properties', 'type': 'PutAliasRequestProperties'}, } diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models_py3.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models_py3.py index e7c5fc7a4349..582451d8f3ba 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models_py3.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/models/_models_py3.py @@ -275,16 +275,22 @@ def __init__(self, **kwargs) -> None: class PutAliasRequest(Model): """The parameters required to create a new subscription. - :param properties: Put alias request properties. + All required parameters must be populated in order to send to Azure. + + :param properties: Required. Put alias request properties. :type properties: ~azure.mgmt.subscription.models.PutAliasRequestProperties """ + _validation = { + 'properties': {'required': True}, + } + _attribute_map = { 'properties': {'key': 'properties', 'type': 'PutAliasRequestProperties'}, } - def __init__(self, *, properties=None, **kwargs) -> None: + def __init__(self, *, properties, **kwargs) -> None: super(PutAliasRequest, self).__init__(**kwargs) self.properties = properties diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/__init__.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/__init__.py index 3406c21e9a24..1aae4ad6020b 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/__init__.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/__init__.py @@ -13,10 +13,12 @@ from ._tenants_operations import TenantsOperations from ._subscription_operations import SubscriptionOperations from ._operations import Operations +from ._alias_operations import AliasOperations __all__ = [ 'SubscriptionsOperations', 'TenantsOperations', 'SubscriptionOperations', 'Operations', + 'AliasOperations', ] diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_alias_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_alias_operations.py new file mode 100644 index 000000000000..106275bc23dc --- /dev/null +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_alias_operations.py @@ -0,0 +1,294 @@ +# 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 AliasOperations(object): + """AliasOperations 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: Version of the API to be used with the client request. Current version is 2020-09-01. Constant value: "2020-09-01". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2020-09-01" + + self.config = config + + + def _create_initial( + self, alias_name, properties, custom_headers=None, raw=False, **operation_config): + body = models.PutAliasRequest(properties=properties) + + # Construct URL + url = self.create.metadata['url'] + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_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 + body_content = self._serialize.body(body, 'PutAliasRequest') + + # 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.ErrorResponseBodyException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PutAliasResponse', response) + if response.status_code == 201: + deserialized = self._deserialize('PutAliasResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def create( + self, alias_name, properties, custom_headers=None, raw=False, polling=True, **operation_config): + """Create Alias Subscription. + + :param alias_name: Alias Name + :type alias_name: str + :param properties: Put alias request properties. + :type properties: + ~azure.mgmt.subscription.models.PutAliasRequestProperties + :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 PutAliasResponse or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.subscription.models.PutAliasResponse] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.subscription.models.PutAliasResponse]] + :raises: + :class:`ErrorResponseBodyException` + """ + raw_result = self._create_initial( + alias_name=alias_name, + properties=properties, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('PutAliasResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + 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.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} + + def get( + self, alias_name, custom_headers=None, raw=False, **operation_config): + """Get Alias Subscription. + + :param alias_name: Alias Name + :type alias_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: PutAliasResponse or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.subscription.models.PutAliasResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseBodyException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_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.ErrorResponseBodyException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PutAliasResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} + + def delete( + self, alias_name, custom_headers=None, raw=False, **operation_config): + """Delete Alias. + + :param alias_name: Alias Name + :type alias_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: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseBodyException` + """ + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'aliasName': self._serialize.url("alias_name", alias_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, 204]: + raise models.ErrorResponseBodyException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} + + def list( + self, custom_headers=None, raw=False, **operation_config): + """Get Alias 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: PutAliasListResult or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.subscription.models.PutAliasListResult or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseBodyException` + """ + # 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') + + # 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.ErrorResponseBodyException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PutAliasListResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list.metadata = {'url': '/providers/Microsoft.Subscription/aliases'} diff --git a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_operations.py b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_operations.py index 85d3e8e9ddc7..02f15f9190ff 100644 --- a/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_operations.py +++ b/sdk/subscription/azure-mgmt-subscription/azure/mgmt/subscription/operations/_subscription_operations.py @@ -11,8 +11,6 @@ import uuid from msrest.pipeline import ClientRawResponse -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling from .. import models @@ -215,256 +213,3 @@ def enable( return deserialized enable.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable'} - - - def _create_alias_initial( - self, alias_name, properties=None, custom_headers=None, raw=False, **operation_config): - body = models.PutAliasRequest(properties=properties) - - # Construct URL - url = self.create_alias.metadata['url'] - path_format_arguments = { - 'aliasName': self._serialize.url("alias_name", alias_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 - body_content = self._serialize.body(body, 'PutAliasRequest') - - # 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.ErrorResponseBodyException(self._deserialize, response) - - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('PutAliasResponse', response) - if response.status_code == 201: - deserialized = self._deserialize('PutAliasResponse', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - def create_alias( - self, alias_name, properties=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Create Alias Subscription. - - :param alias_name: Alias Name - :type alias_name: str - :param properties: Put alias request properties. - :type properties: - ~azure.mgmt.subscription.models.PutAliasRequestProperties - :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 PutAliasResponse or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.subscription.models.PutAliasResponse] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.subscription.models.PutAliasResponse]] - :raises: - :class:`ErrorResponseBodyException` - """ - raw_result = self._create_alias_initial( - alias_name=alias_name, - properties=properties, - custom_headers=custom_headers, - raw=True, - **operation_config - ) - - def get_long_running_output(response): - deserialized = self._deserialize('PutAliasResponse', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - 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_alias.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} - - def get_alias( - self, alias_name, custom_headers=None, raw=False, **operation_config): - """Get Alias Subscription. - - :param alias_name: Alias Name - :type alias_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: PutAliasResponse or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.subscription.models.PutAliasResponse or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseBodyException` - """ - # Construct URL - url = self.get_alias.metadata['url'] - path_format_arguments = { - 'aliasName': self._serialize.url("alias_name", alias_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.ErrorResponseBodyException(self._deserialize, response) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PutAliasResponse', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_alias.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} - - def delete_alias( - self, alias_name, custom_headers=None, raw=False, **operation_config): - """Delete Alias. - - :param alias_name: Alias Name - :type alias_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: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseBodyException` - """ - # Construct URL - url = self.delete_alias.metadata['url'] - path_format_arguments = { - 'aliasName': self._serialize.url("alias_name", alias_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, 204]: - raise models.ErrorResponseBodyException(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_alias.metadata = {'url': '/providers/Microsoft.Subscription/aliases/{aliasName}'} - - def list_alias( - self, custom_headers=None, raw=False, **operation_config): - """Get Alias 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: PutAliasListResult or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.subscription.models.PutAliasListResult or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseBodyException` - """ - # Construct URL - url = self.list_alias.metadata['url'] - - # 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.ErrorResponseBodyException(self._deserialize, response) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PutAliasListResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - list_alias.metadata = {'url': '/providers/Microsoft.Subscription/aliases'}