From 2e895301a0b26afac2333393e2571d7bb07dc7bc Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 19 Mar 2018 06:44:38 +0000 Subject: [PATCH 1/2] Generated from ca9c4de09c4178deac069e4260482bc76e806d56 Adding patch API for Configurations --- .../azure/mgmt/automation/models/__init__.py | 2 + .../dsc_configuration_update_parameters.py | 61 +++++++++++++++ .../dsc_configuration_operations.py | 75 +++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 azure-mgmt-automation/azure/mgmt/automation/models/dsc_configuration_update_parameters.py diff --git a/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py b/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py index fe36311fa244..5cf4ac3af9f0 100644 --- a/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py +++ b/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py @@ -57,6 +57,7 @@ from .job_provisioning_state_property import JobProvisioningStateProperty from .dsc_compilation_job import DscCompilationJob from .dsc_configuration_create_or_update_parameters import DscConfigurationCreateOrUpdateParameters +from .dsc_configuration_update_parameters import DscConfigurationUpdateParameters from .dsc_meta_configuration import DscMetaConfiguration from .dsc_node_configuration_association_property import DscNodeConfigurationAssociationProperty from .dsc_node_extension_handler_association_property import DscNodeExtensionHandlerAssociationProperty @@ -223,6 +224,7 @@ 'JobProvisioningStateProperty', 'DscCompilationJob', 'DscConfigurationCreateOrUpdateParameters', + 'DscConfigurationUpdateParameters', 'DscMetaConfiguration', 'DscNodeConfigurationAssociationProperty', 'DscNodeExtensionHandlerAssociationProperty', diff --git a/azure-mgmt-automation/azure/mgmt/automation/models/dsc_configuration_update_parameters.py b/azure-mgmt-automation/azure/mgmt/automation/models/dsc_configuration_update_parameters.py new file mode 100644 index 000000000000..7b1534337756 --- /dev/null +++ b/azure-mgmt-automation/azure/mgmt/automation/models/dsc_configuration_update_parameters.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.serialization import Model + + +class DscConfigurationUpdateParameters(Model): + """The parameters supplied to the create or update configuration operation. + + :param log_verbose: Gets or sets verbose log option. + :type log_verbose: bool + :param log_progress: Gets or sets progress log option. + :type log_progress: bool + :param source: Gets or sets the source. + :type source: ~azure.mgmt.automation.models.ContentSource + :param parameters: Gets or sets the configuration parameters. + :type parameters: dict[str, + ~azure.mgmt.automation.models.DscConfigurationParameter] + :param description: Gets or sets the description of the configuration. + :type description: str + :param name: Gets or sets name of the resource. + :type name: str + :param location: Gets or sets the location of the resource. + :type location: str + :param tags: Gets or sets the tags attached to the resource. + :type tags: dict[str, str] + """ + + _validation = { + 'source': {'required': True}, + } + + _attribute_map = { + 'log_verbose': {'key': 'properties.logVerbose', 'type': 'bool'}, + 'log_progress': {'key': 'properties.logProgress', 'type': 'bool'}, + 'source': {'key': 'properties.source', 'type': 'ContentSource'}, + 'parameters': {'key': 'properties.parameters', 'type': '{DscConfigurationParameter}'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, source, log_verbose=None, log_progress=None, parameters=None, description=None, name=None, location=None, tags=None): + super(DscConfigurationUpdateParameters, self).__init__() + self.log_verbose = log_verbose + self.log_progress = log_progress + self.source = source + self.parameters = parameters + self.description = description + self.name = name + self.location = location + self.tags = tags diff --git a/azure-mgmt-automation/azure/mgmt/automation/operations/dsc_configuration_operations.py b/azure-mgmt-automation/azure/mgmt/automation/operations/dsc_configuration_operations.py index 16c68f60b46e..ce660646ae2e 100644 --- a/azure-mgmt-automation/azure/mgmt/automation/operations/dsc_configuration_operations.py +++ b/azure-mgmt-automation/azure/mgmt/automation/operations/dsc_configuration_operations.py @@ -224,6 +224,81 @@ def create_or_update( return deserialized create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} + def update( + self, automation_account_name, configuration_name, parameters=None, custom_headers=None, raw=False, **operation_config): + """Create the configuration identified by configuration name. + + :param automation_account_name: The automation account name. + :type automation_account_name: str + :param configuration_name: The create or update parameters for + configuration. + :type configuration_name: str + :param parameters: The create or update parameters for configuration. + :type parameters: + ~azure.mgmt.automation.models.DscConfigurationUpdateParameters + :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: DscConfiguration or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.automation.models.DscConfiguration or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("self.config.resource_group_name", self.config.resource_group_name, 'str', pattern=r'^[-\w\._]+$'), + 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), + '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['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, 'DscConfigurationUpdateParameters') + else: + body_content = None + + # Construct and send request + request = self._client.patch(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, 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('DscConfiguration', response) + if response.status_code == 201: + deserialized = self._deserialize('DscConfiguration', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} + def get_content( self, automation_account_name, configuration_name, custom_headers=None, raw=False, **operation_config): """Retrieve the configuration script identified by configuration name. From 109eb88c375ac19de45313f38c8c38e29d6434d7 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Thu, 22 Mar 2018 03:05:38 +0000 Subject: [PATCH 2/2] Generated from d55be73815a24c1ea54f397922ac7bc4dc11289a Adding patch API for Configurations --- .../azure/mgmt/automation/models/__init__.py | 12 ++++++------ .../models/dsc_configuration_update_parameters.py | 6 +----- .../operations/dsc_configuration_operations.py | 4 +--- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py b/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py index 5cf4ac3af9f0..8f5d82cf0552 100644 --- a/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py +++ b/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py @@ -59,11 +59,9 @@ from .dsc_configuration_create_or_update_parameters import DscConfigurationCreateOrUpdateParameters from .dsc_configuration_update_parameters import DscConfigurationUpdateParameters from .dsc_meta_configuration import DscMetaConfiguration +from .dsc_node_configuration_create_or_update_parameters import DscNodeConfigurationCreateOrUpdateParameters from .dsc_node_configuration_association_property import DscNodeConfigurationAssociationProperty from .dsc_node_extension_handler_association_property import DscNodeExtensionHandlerAssociationProperty -from .dsc_node import DscNode -from .dsc_node_configuration_create_or_update_parameters import DscNodeConfigurationCreateOrUpdateParameters -from .dsc_node_configuration import DscNodeConfiguration from .dsc_node_update_parameters import DscNodeUpdateParameters from .dsc_report_error import DscReportError from .dsc_report_resource_navigation import DscReportResourceNavigation @@ -105,6 +103,8 @@ from .webhook_create_or_update_parameters import WebhookCreateOrUpdateParameters from .webhook import Webhook from .webhook_update_parameters import WebhookUpdateParameters +from .dsc_node import DscNode +from .dsc_node_configuration import DscNodeConfiguration from .collection_item_update_configuration import CollectionItemUpdateConfiguration from .software_update_configuration_collection_item import SoftwareUpdateConfigurationCollectionItem from .software_update_configuration_list_result import SoftwareUpdateConfigurationListResult @@ -226,11 +226,9 @@ 'DscConfigurationCreateOrUpdateParameters', 'DscConfigurationUpdateParameters', 'DscMetaConfiguration', + 'DscNodeConfigurationCreateOrUpdateParameters', 'DscNodeConfigurationAssociationProperty', 'DscNodeExtensionHandlerAssociationProperty', - 'DscNode', - 'DscNodeConfigurationCreateOrUpdateParameters', - 'DscNodeConfiguration', 'DscNodeUpdateParameters', 'DscReportError', 'DscReportResourceNavigation', @@ -272,6 +270,8 @@ 'WebhookCreateOrUpdateParameters', 'Webhook', 'WebhookUpdateParameters', + 'DscNode', + 'DscNodeConfiguration', 'CollectionItemUpdateConfiguration', 'SoftwareUpdateConfigurationCollectionItem', 'SoftwareUpdateConfigurationListResult', diff --git a/azure-mgmt-automation/azure/mgmt/automation/models/dsc_configuration_update_parameters.py b/azure-mgmt-automation/azure/mgmt/automation/models/dsc_configuration_update_parameters.py index 7b1534337756..f7f86dcd3b6c 100644 --- a/azure-mgmt-automation/azure/mgmt/automation/models/dsc_configuration_update_parameters.py +++ b/azure-mgmt-automation/azure/mgmt/automation/models/dsc_configuration_update_parameters.py @@ -28,8 +28,6 @@ class DscConfigurationUpdateParameters(Model): :type description: str :param name: Gets or sets name of the resource. :type name: str - :param location: Gets or sets the location of the resource. - :type location: str :param tags: Gets or sets the tags attached to the resource. :type tags: dict[str, str] """ @@ -45,11 +43,10 @@ class DscConfigurationUpdateParameters(Model): 'parameters': {'key': 'properties.parameters', 'type': '{DscConfigurationParameter}'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, source, log_verbose=None, log_progress=None, parameters=None, description=None, name=None, location=None, tags=None): + def __init__(self, source, log_verbose=None, log_progress=None, parameters=None, description=None, name=None, tags=None): super(DscConfigurationUpdateParameters, self).__init__() self.log_verbose = log_verbose self.log_progress = log_progress @@ -57,5 +54,4 @@ def __init__(self, source, log_verbose=None, log_progress=None, parameters=None, self.parameters = parameters self.description = description self.name = name - self.location = location self.tags = tags diff --git a/azure-mgmt-automation/azure/mgmt/automation/operations/dsc_configuration_operations.py b/azure-mgmt-automation/azure/mgmt/automation/operations/dsc_configuration_operations.py index ce660646ae2e..97210d3991eb 100644 --- a/azure-mgmt-automation/azure/mgmt/automation/operations/dsc_configuration_operations.py +++ b/azure-mgmt-automation/azure/mgmt/automation/operations/dsc_configuration_operations.py @@ -282,15 +282,13 @@ def update( response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) - if response.status_code not in [200, 201]: + if response.status_code not in [200]: raise models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('DscConfiguration', response) - if response.status_code == 201: - deserialized = self._deserialize('DscConfiguration', response) if raw: client_raw_response = ClientRawResponse(deserialized, response)