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 5eb207496bdd..f975d04182c4 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 @@ -11,6 +11,7 @@ import uuid from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError from .. import models @@ -305,7 +306,7 @@ def update( update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}'} def get_content( - self, resource_group_name, automation_account_name, configuration_name, custom_headers=None, raw=False, **operation_config): + self, resource_group_name, automation_account_name, configuration_name, custom_headers=None, raw=False, callback=None, **operation_config): """Retrieve the configuration script identified by configuration name. :param resource_group_name: Name of an Azure Resource group. @@ -317,12 +318,16 @@ 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 - :raises: - :class:`ErrorResponseException` + :return: object or ClientRawResponse if raw=true + :rtype: Generator or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` """ # Construct URL url = self.get_content.metadata['url'] @@ -340,7 +345,7 @@ def get_content( # Construct headers header_parameters = {} - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = 'text/powershell' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: @@ -350,15 +355,17 @@ 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]: - raise models.ErrorResponseException(self._deserialize, response) + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp 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)