From f7805b811667f79f14d67413c5fe2d2a0e98c613 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Thu, 27 Sep 2018 16:17:31 +0000 Subject: [PATCH 1/2] Generated from 510e17781037581020c980bca0f6b0a7bf77a931 Fix the runbook resource schema issues --- .../operations/runbook_draft_operations.py | 21 ++++++++++--------- .../operations/runbook_operations.py | 15 ++++++++----- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/azure-mgmt-automation/azure/mgmt/automation/operations/runbook_draft_operations.py b/azure-mgmt-automation/azure/mgmt/automation/operations/runbook_draft_operations.py index e709b3f3bad6..5db521d37a19 100644 --- a/azure-mgmt-automation/azure/mgmt/automation/operations/runbook_draft_operations.py +++ b/azure-mgmt-automation/azure/mgmt/automation/operations/runbook_draft_operations.py @@ -110,7 +110,7 @@ def get_content( def _replace_content_initial( - self, resource_group_name, automation_account_name, runbook_name, runbook_content, custom_headers=None, raw=False, **operation_config): + self, resource_group_name, automation_account_name, runbook_name, runbook_content, custom_headers=None, raw=False, callback=None, **operation_config): # Construct URL url = self.replace_content.metadata['url'] path_format_arguments = { @@ -137,7 +137,7 @@ def _replace_content_initial( header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body - body_content = self._serialize.body(runbook_content, 'str') + body_content = upload_gen(runbook_content) # Construct and send request request = self._client.put(url, query_parameters, header_parameters, body_content) @@ -150,7 +150,7 @@ def _replace_content_initial( header_dict = {} if response.status_code == 200: - deserialized = self._deserialize('str', response) + deserialized = self._deserialize('object', response) header_dict = { 'location': 'str', } @@ -163,7 +163,7 @@ def _replace_content_initial( return deserialized def replace_content( - self, resource_group_name, automation_account_name, runbook_name, runbook_content, custom_headers=None, raw=False, polling=True, **operation_config): + self, resource_group_name, automation_account_name, runbook_name, runbook_content, custom_headers=None, raw=False, callback=None, polling=True, **operation_config): """Replaces the runbook draft content. :param resource_group_name: Name of an Azure Resource group. @@ -173,16 +173,17 @@ def replace_content( :param runbook_name: The runbook name. :type runbook_name: str :param runbook_content: The runbook draft content. - :type runbook_content: str + :type runbook_content: Generator :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 str or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[str] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[str]] + :return: An instance of LROPoller that returns object or + ClientRawResponse if raw==True + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[Generator] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[Generator]] :raises: :class:`ErrorResponseException` """ @@ -200,7 +201,7 @@ def get_long_running_output(response): header_dict = { 'location': 'str', } - deserialized = self._deserialize('str', response) + deserialized = self._deserialize('object', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) diff --git a/azure-mgmt-automation/azure/mgmt/automation/operations/runbook_operations.py b/azure-mgmt-automation/azure/mgmt/automation/operations/runbook_operations.py index 8e0de36b282b..61fa9bf6ecd3 100644 --- a/azure-mgmt-automation/azure/mgmt/automation/operations/runbook_operations.py +++ b/azure-mgmt-automation/azure/mgmt/automation/operations/runbook_operations.py @@ -130,7 +130,7 @@ def get_long_running_output(response): publish.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/runbooks/{runbookName}/publish'} def get_content( - self, resource_group_name, automation_account_name, runbook_name, custom_headers=None, raw=False, **operation_config): + self, resource_group_name, automation_account_name, runbook_name, custom_headers=None, raw=False, callback=None, **operation_config): """Retrieve the content of runbook identified by runbook name. :param resource_group_name: Name of an Azure Resource group. @@ -142,10 +142,15 @@ def get_content( :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response + :param callback: When specified, will be called with each chunk of + data that is streamed. The callback should take two arguments, the + bytes of the current chunk of data and the response object. If the + data is uploading, response will be None. + :type callback: Callable[Bytes, response=None] :param operation_config: :ref:`Operation configuration overrides`. - :return: str or ClientRawResponse if raw=true - :rtype: str or ~msrest.pipeline.ClientRawResponse + :return: object or ClientRawResponse if raw=true + :rtype: Generator or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ # Construct URL @@ -174,7 +179,7 @@ def get_content( # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + response = self._client.send(request, stream=True, **operation_config) if response.status_code not in [200]: exp = CloudError(response) @@ -184,7 +189,7 @@ def get_content( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('str', response) + deserialized = self._client.stream_download(response, callback) if raw: client_raw_response = ClientRawResponse(deserialized, response) From ed459b2b64df0ecee2a1ba1af1f6f4e2d5ad84c7 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 8 Oct 2018 20:14:57 +0000 Subject: [PATCH 2/2] Generated from 510e17781037581020c980bca0f6b0a7bf77a931 Fix the runbook resource schema issues --- .../mgmt/automation/automation_client.py | 5 + .../azure/mgmt/automation/models/__init__.py | 6 + .../python_package_create_parameters.py | 38 ++ .../python_package_create_parameters_py3.py | 38 ++ .../python_package_update_parameters.py | 28 ++ .../python_package_update_parameters_py3.py | 28 ++ .../mgmt/automation/operations/__init__.py | 2 + .../operations/python2_package_operations.py | 373 ++++++++++++++++++ 8 files changed, 518 insertions(+) create mode 100644 azure-mgmt-automation/azure/mgmt/automation/models/python_package_create_parameters.py create mode 100644 azure-mgmt-automation/azure/mgmt/automation/models/python_package_create_parameters_py3.py create mode 100644 azure-mgmt-automation/azure/mgmt/automation/models/python_package_update_parameters.py create mode 100644 azure-mgmt-automation/azure/mgmt/automation/models/python_package_update_parameters_py3.py create mode 100644 azure-mgmt-automation/azure/mgmt/automation/operations/python2_package_operations.py diff --git a/azure-mgmt-automation/azure/mgmt/automation/automation_client.py b/azure-mgmt-automation/azure/mgmt/automation/automation_client.py index 5b2926ecd3ed..3fdd4edb0b85 100644 --- a/azure-mgmt-automation/azure/mgmt/automation/automation_client.py +++ b/azure-mgmt-automation/azure/mgmt/automation/automation_client.py @@ -53,6 +53,7 @@ from .operations.runbook_operations import RunbookOperations from .operations.test_job_streams_operations import TestJobStreamsOperations from .operations.test_job_operations import TestJobOperations +from .operations.python2_package_operations import Python2PackageOperations from . import models @@ -182,6 +183,8 @@ class AutomationClient(SDKClient): :vartype test_job_streams: azure.mgmt.automation.operations.TestJobStreamsOperations :ivar test_job: TestJob operations :vartype test_job: azure.mgmt.automation.operations.TestJobOperations + :ivar python2_package: Python2Package operations + :vartype python2_package: azure.mgmt.automation.operations.Python2PackageOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -286,3 +289,5 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.test_job = TestJobOperations( self._client, self.config, self._serialize, self._deserialize) + self.python2_package = Python2PackageOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py b/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py index 71e2afbed9c7..dc9f43c635b7 100644 --- a/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py +++ b/azure-mgmt-automation/azure/mgmt/automation/models/__init__.py @@ -135,6 +135,8 @@ from .test_job_py3 import TestJob from .runbook_create_or_update_draft_properties_py3 import RunbookCreateOrUpdateDraftProperties from .runbook_create_or_update_draft_parameters_py3 import RunbookCreateOrUpdateDraftParameters + from .python_package_create_parameters_py3 import PythonPackageCreateParameters + from .python_package_update_parameters_py3 import PythonPackageUpdateParameters except (SyntaxError, ImportError): from .sku import Sku from .automation_account import AutomationAccount @@ -261,6 +263,8 @@ from .test_job import TestJob from .runbook_create_or_update_draft_properties import RunbookCreateOrUpdateDraftProperties from .runbook_create_or_update_draft_parameters import RunbookCreateOrUpdateDraftParameters + from .python_package_create_parameters import PythonPackageCreateParameters + from .python_package_update_parameters import PythonPackageUpdateParameters from .automation_account_paged import AutomationAccountPaged from .operation_paged import OperationPaged from .statistics_paged import StatisticsPaged @@ -446,6 +450,8 @@ 'TestJob', 'RunbookCreateOrUpdateDraftProperties', 'RunbookCreateOrUpdateDraftParameters', + 'PythonPackageCreateParameters', + 'PythonPackageUpdateParameters', 'AutomationAccountPaged', 'OperationPaged', 'StatisticsPaged', diff --git a/azure-mgmt-automation/azure/mgmt/automation/models/python_package_create_parameters.py b/azure-mgmt-automation/azure/mgmt/automation/models/python_package_create_parameters.py new file mode 100644 index 000000000000..adf98c820ba6 --- /dev/null +++ b/azure-mgmt-automation/azure/mgmt/automation/models/python_package_create_parameters.py @@ -0,0 +1,38 @@ +# 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 PythonPackageCreateParameters(Model): + """The parameters supplied to the create or update module operation. + + All required parameters must be populated in order to send to Azure. + + :param content_link: Required. Gets or sets the module content link. + :type content_link: ~azure.mgmt.automation.models.ContentLink + :param tags: Gets or sets the tags attached to the resource. + :type tags: dict[str, str] + """ + + _validation = { + 'content_link': {'required': True}, + } + + _attribute_map = { + 'content_link': {'key': 'properties.contentLink', 'type': 'ContentLink'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, **kwargs): + super(PythonPackageCreateParameters, self).__init__(**kwargs) + self.content_link = kwargs.get('content_link', None) + self.tags = kwargs.get('tags', None) diff --git a/azure-mgmt-automation/azure/mgmt/automation/models/python_package_create_parameters_py3.py b/azure-mgmt-automation/azure/mgmt/automation/models/python_package_create_parameters_py3.py new file mode 100644 index 000000000000..24ad5f759021 --- /dev/null +++ b/azure-mgmt-automation/azure/mgmt/automation/models/python_package_create_parameters_py3.py @@ -0,0 +1,38 @@ +# 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 PythonPackageCreateParameters(Model): + """The parameters supplied to the create or update module operation. + + All required parameters must be populated in order to send to Azure. + + :param content_link: Required. Gets or sets the module content link. + :type content_link: ~azure.mgmt.automation.models.ContentLink + :param tags: Gets or sets the tags attached to the resource. + :type tags: dict[str, str] + """ + + _validation = { + 'content_link': {'required': True}, + } + + _attribute_map = { + 'content_link': {'key': 'properties.contentLink', 'type': 'ContentLink'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, *, content_link, tags=None, **kwargs) -> None: + super(PythonPackageCreateParameters, self).__init__(**kwargs) + self.content_link = content_link + self.tags = tags diff --git a/azure-mgmt-automation/azure/mgmt/automation/models/python_package_update_parameters.py b/azure-mgmt-automation/azure/mgmt/automation/models/python_package_update_parameters.py new file mode 100644 index 000000000000..df4f0aef03b9 --- /dev/null +++ b/azure-mgmt-automation/azure/mgmt/automation/models/python_package_update_parameters.py @@ -0,0 +1,28 @@ +# 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 PythonPackageUpdateParameters(Model): + """The parameters supplied to the update module operation. + + :param tags: Gets or sets the tags attached to the resource. + :type tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, **kwargs): + super(PythonPackageUpdateParameters, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) diff --git a/azure-mgmt-automation/azure/mgmt/automation/models/python_package_update_parameters_py3.py b/azure-mgmt-automation/azure/mgmt/automation/models/python_package_update_parameters_py3.py new file mode 100644 index 000000000000..e45e747186fd --- /dev/null +++ b/azure-mgmt-automation/azure/mgmt/automation/models/python_package_update_parameters_py3.py @@ -0,0 +1,28 @@ +# 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 PythonPackageUpdateParameters(Model): + """The parameters supplied to the update module operation. + + :param tags: Gets or sets the tags attached to the resource. + :type tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, *, tags=None, **kwargs) -> None: + super(PythonPackageUpdateParameters, self).__init__(**kwargs) + self.tags = tags diff --git a/azure-mgmt-automation/azure/mgmt/automation/operations/__init__.py b/azure-mgmt-automation/azure/mgmt/automation/operations/__init__.py index 25f505bff5fc..6d2361041121 100644 --- a/azure-mgmt-automation/azure/mgmt/automation/operations/__init__.py +++ b/azure-mgmt-automation/azure/mgmt/automation/operations/__init__.py @@ -49,6 +49,7 @@ from .runbook_operations import RunbookOperations from .test_job_streams_operations import TestJobStreamsOperations from .test_job_operations import TestJobOperations +from .python2_package_operations import Python2PackageOperations __all__ = [ 'AutomationAccountOperations', @@ -91,4 +92,5 @@ 'RunbookOperations', 'TestJobStreamsOperations', 'TestJobOperations', + 'Python2PackageOperations', ] diff --git a/azure-mgmt-automation/azure/mgmt/automation/operations/python2_package_operations.py b/azure-mgmt-automation/azure/mgmt/automation/operations/python2_package_operations.py new file mode 100644 index 000000000000..6dd63eb65c39 --- /dev/null +++ b/azure-mgmt-automation/azure/mgmt/automation/operations/python2_package_operations.py @@ -0,0 +1,373 @@ +# 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 Python2PackageOperations(object): + """Python2PackageOperations operations. + + :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: "2018-06-30". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-06-30" + + self.config = config + + def delete( + self, resource_group_name, automation_account_name, package_name, custom_headers=None, raw=False, **operation_config): + """Delete the python 2 package by name. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param package_name: The python package name. + :type package_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:`ErrorResponseException` + """ + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), + 'packageName': self._serialize.url("package_name", package_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 = {} + 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]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}'} + + def get( + self, resource_group_name, automation_account_name, package_name, custom_headers=None, raw=False, **operation_config): + """Retrieve the python 2 package identified by package name. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param package_name: The python package name. + :type package_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: Module or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.automation.models.Module or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), + 'packageName': self._serialize.url("package_name", package_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['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('Module', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}'} + + def create_or_update( + self, resource_group_name, automation_account_name, package_name, content_link, tags=None, custom_headers=None, raw=False, **operation_config): + """Create or Update the python 2 package identified by package name. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param package_name: The name of python package. + :type package_name: str + :param content_link: Gets or sets the module content link. + :type content_link: ~azure.mgmt.automation.models.ContentLink + :param tags: Gets or sets the tags attached to 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: Module or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.automation.models.Module or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + parameters = models.PythonPackageCreateParameters(content_link=content_link, tags=tags) + + # Construct URL + url = self.create_or_update.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), + 'packageName': self._serialize.url("package_name", package_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['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(parameters, 'PythonPackageCreateParameters') + + # 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 + + if response.status_code == 200: + deserialized = self._deserialize('Module', response) + if response.status_code == 201: + deserialized = self._deserialize('Module', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages/{packageName}'} + + def update( + self, resource_group_name, automation_account_name, package_name, tags=None, custom_headers=None, raw=False, **operation_config): + """Update the python 2 package identified by package name. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_name: str + :param package_name: The name of python package. + :type package_name: str + :param tags: Gets or sets the tags attached to 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: Module or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.automation.models.Module or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + parameters = models.PythonPackageUpdateParameters(tags=tags) + + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + 'automationAccountName': self._serialize.url("automation_account_name", automation_account_name, 'str'), + 'packageName': self._serialize.url("package_name", package_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['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(parameters, 'PythonPackageUpdateParameters') + + # 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('Module', 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}/python2Packages/{packageName}'} + + def list_by_automation_account( + self, resource_group_name, automation_account_name, custom_headers=None, raw=False, **operation_config): + """Retrieve a list of python 2 packages. + + :param resource_group_name: Name of an Azure Resource group. + :type resource_group_name: str + :param automation_account_name: The name of the automation account. + :type automation_account_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 Module + :rtype: + ~azure.mgmt.automation.models.ModulePaged[~azure.mgmt.automation.models.Module] + :raises: + :class:`ErrorResponseException` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list_by_automation_account.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._]+$'), + 'automationAccountName': self._serialize.url("automation_account_name", automation_account_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') + + 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) + 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 + deserialized = models.ModulePaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.ModulePaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list_by_automation_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/python2Packages'}