Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import uuid
from msrest.pipeline import ClientRawResponse
from msrestazure.azure_exceptions import CloudError

from .. import models

Expand Down Expand Up @@ -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.
Expand All @@ -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<msrest:optionsforoperations>`.
:return: str or ClientRawResponse if raw=true
:rtype: str or ~msrest.pipeline.ClientRawResponse
:raises:
:class:`ErrorResponseException<azure.mgmt.automation.models.ErrorResponseException>`
:return: object or ClientRawResponse if raw=true
:rtype: Generator or ~msrest.pipeline.ClientRawResponse
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
"""
# Construct URL
url = self.get_content.metadata['url']
Expand All @@ -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:
Expand All @@ -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)
Expand Down