Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR compute/resource-manager] Update RunCommand operation output as valid json object #2888

Merged
merged 2 commits into from
Jul 10, 2018
Merged
Show file tree
Hide file tree
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
42 changes: 42 additions & 0 deletions azure-mgmt-compute/azure/mgmt/compute/compute_management_client.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@


class RunCommandResult(Model):
"""Run command operation response.
"""RunCommandResult.

:param output: Operation output data (raw JSON)
:type output: object
:param value: Run command operation response.
:type value:
list[~azure.mgmt.compute.v2018_04_01.models.InstanceViewStatus]
"""

_attribute_map = {
'output': {'key': 'properties.output', 'type': 'object'},
'value': {'key': 'value', 'type': '[InstanceViewStatus]'},
}

def __init__(self, **kwargs):
super(RunCommandResult, self).__init__(**kwargs)
self.output = kwargs.get('output', None)
self.value = kwargs.get('value', None)
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@


class RunCommandResult(Model):
"""Run command operation response.
"""RunCommandResult.

:param output: Operation output data (raw JSON)
:type output: object
:param value: Run command operation response.
:type value:
list[~azure.mgmt.compute.v2018_04_01.models.InstanceViewStatus]
"""

_attribute_map = {
'output': {'key': 'properties.output', 'type': 'object'},
'value': {'key': 'value', 'type': '[InstanceViewStatus]'},
}

def __init__(self, *, output=None, **kwargs) -> None:
def __init__(self, *, value=None, **kwargs) -> None:
super(RunCommandResult, self).__init__(**kwargs)
self.output = output
self.value = value
Original file line number Diff line number Diff line change
Expand Up @@ -1129,3 +1129,108 @@ def get_long_running_output(response):
else: polling_method = polling
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
perform_maintenance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance'}


def _run_command_initial(
self, resource_group_name, vm_scale_set_name, instance_id, parameters, custom_headers=None, raw=False, **operation_config):
# Construct URL
url = self.run_command.metadata['url']
path_format_arguments = {
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
'instanceId': self._serialize.url("instance_id", instance_id, '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
body_content = self._serialize.body(parameters, 'RunCommandInput')

# Construct and send request
request = self._client.post(url, query_parameters)
response = self._client.send(
request, header_parameters, body_content, stream=False, **operation_config)

if response.status_code not in [200, 202]:
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('RunCommandResult', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response

return deserialized

def run_command(
self, resource_group_name, vm_scale_set_name, instance_id, parameters, custom_headers=None, raw=False, polling=True, **operation_config):
"""Run command on a virtual machine in a VM scale set.

:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param vm_scale_set_name: The name of the VM scale set.
:type vm_scale_set_name: str
:param instance_id: The instance ID of the virtual machine.
:type instance_id: str
:param parameters: Parameters supplied to the Run command operation.
:type parameters:
~azure.mgmt.compute.v2018_04_01.models.RunCommandInput
: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 RunCommandResult or
ClientRawResponse<RunCommandResult> if raw==True
:rtype:
~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.compute.v2018_04_01.models.RunCommandResult]
or
~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.compute.v2018_04_01.models.RunCommandResult]]
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
"""
raw_result = self._run_command_initial(
resource_group_name=resource_group_name,
vm_scale_set_name=vm_scale_set_name,
instance_id=instance_id,
parameters=parameters,
custom_headers=custom_headers,
raw=True,
**operation_config
)

def get_long_running_output(response):
deserialized = self._deserialize('RunCommandResult', 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)
run_command.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand'}
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ def _run_command_initial(
deserialized = None

if response.status_code == 200:
deserialized = self._deserialize('[InstanceViewStatus]', response)
deserialized = self._deserialize('RunCommandResult', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
Expand All @@ -1458,12 +1458,12 @@ def run_command(
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 list or
ClientRawResponse<list> if raw==True
:return: An instance of LROPoller that returns RunCommandResult or
ClientRawResponse<RunCommandResult> if raw==True
:rtype:
~msrestazure.azure_operation.AzureOperationPoller[list[~azure.mgmt.compute.v2018_04_01.models.InstanceViewStatus]]
~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.compute.v2018_04_01.models.RunCommandResult]
or
~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[list[~azure.mgmt.compute.v2018_04_01.models.InstanceViewStatus]]]
~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.compute.v2018_04_01.models.RunCommandResult]]
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
"""
raw_result = self._run_command_initial(
Expand All @@ -1476,7 +1476,7 @@ def run_command(
)

def get_long_running_output(response):
deserialized = self._deserialize('[InstanceViewStatus]', response)
deserialized = self._deserialize('RunCommandResult', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@
from msrest import Serializer, Deserializer
from msrestazure import AzureConfiguration
from .version import VERSION
from .operations.operations import Operations
from .operations.availability_sets_operations import AvailabilitySetsOperations
from .operations.virtual_machine_extension_images_operations import VirtualMachineExtensionImagesOperations
from .operations.virtual_machine_extensions_operations import VirtualMachineExtensionsOperations
from .operations.virtual_machine_images_operations import VirtualMachineImagesOperations
from .operations.usage_operations import UsageOperations
from .operations.virtual_machine_sizes_operations import VirtualMachineSizesOperations
from .operations.images_operations import ImagesOperations
from .operations.virtual_machines_operations import VirtualMachinesOperations
from .operations.virtual_machine_scale_sets_operations import VirtualMachineScaleSetsOperations
from .operations.virtual_machine_scale_set_extensions_operations import VirtualMachineScaleSetExtensionsOperations
from .operations.virtual_machine_scale_set_rolling_upgrades_operations import VirtualMachineScaleSetRollingUpgradesOperations
from .operations.virtual_machine_scale_set_vms_operations import VirtualMachineScaleSetVMsOperations
from .operations.log_analytics_operations import LogAnalyticsOperations
from .operations.galleries_operations import GalleriesOperations
from .operations.gallery_images_operations import GalleryImagesOperations
from .operations.gallery_image_versions_operations import GalleryImageVersionsOperations
Expand Down Expand Up @@ -59,6 +73,34 @@ class ComputeManagementClient(SDKClient):
:ivar config: Configuration for client.
:vartype config: ComputeManagementClientConfiguration

:ivar operations: Operations operations
:vartype operations: azure.mgmt.compute.v2018_06_01.operations.Operations
:ivar availability_sets: AvailabilitySets operations
:vartype availability_sets: azure.mgmt.compute.v2018_06_01.operations.AvailabilitySetsOperations
:ivar virtual_machine_extension_images: VirtualMachineExtensionImages operations
:vartype virtual_machine_extension_images: azure.mgmt.compute.v2018_06_01.operations.VirtualMachineExtensionImagesOperations
:ivar virtual_machine_extensions: VirtualMachineExtensions operations
:vartype virtual_machine_extensions: azure.mgmt.compute.v2018_06_01.operations.VirtualMachineExtensionsOperations
:ivar virtual_machine_images: VirtualMachineImages operations
:vartype virtual_machine_images: azure.mgmt.compute.v2018_06_01.operations.VirtualMachineImagesOperations
:ivar usage: Usage operations
:vartype usage: azure.mgmt.compute.v2018_06_01.operations.UsageOperations
:ivar virtual_machine_sizes: VirtualMachineSizes operations
:vartype virtual_machine_sizes: azure.mgmt.compute.v2018_06_01.operations.VirtualMachineSizesOperations
:ivar images: Images operations
:vartype images: azure.mgmt.compute.v2018_06_01.operations.ImagesOperations
:ivar virtual_machines: VirtualMachines operations
:vartype virtual_machines: azure.mgmt.compute.v2018_06_01.operations.VirtualMachinesOperations
:ivar virtual_machine_scale_sets: VirtualMachineScaleSets operations
:vartype virtual_machine_scale_sets: azure.mgmt.compute.v2018_06_01.operations.VirtualMachineScaleSetsOperations
:ivar virtual_machine_scale_set_extensions: VirtualMachineScaleSetExtensions operations
:vartype virtual_machine_scale_set_extensions: azure.mgmt.compute.v2018_06_01.operations.VirtualMachineScaleSetExtensionsOperations
:ivar virtual_machine_scale_set_rolling_upgrades: VirtualMachineScaleSetRollingUpgrades operations
:vartype virtual_machine_scale_set_rolling_upgrades: azure.mgmt.compute.v2018_06_01.operations.VirtualMachineScaleSetRollingUpgradesOperations
:ivar virtual_machine_scale_set_vms: VirtualMachineScaleSetVMs operations
:vartype virtual_machine_scale_set_vms: azure.mgmt.compute.v2018_06_01.operations.VirtualMachineScaleSetVMsOperations
:ivar log_analytics: LogAnalytics operations
:vartype log_analytics: azure.mgmt.compute.v2018_06_01.operations.LogAnalyticsOperations
:ivar galleries: Galleries operations
:vartype galleries: azure.mgmt.compute.v2018_06_01.operations.GalleriesOperations
:ivar gallery_images: GalleryImages operations
Expand Down Expand Up @@ -87,6 +129,34 @@ def __init__(
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)

self.operations = Operations(
self._client, self.config, self._serialize, self._deserialize)
self.availability_sets = AvailabilitySetsOperations(
self._client, self.config, self._serialize, self._deserialize)
self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(
self._client, self.config, self._serialize, self._deserialize)
self.virtual_machine_extensions = VirtualMachineExtensionsOperations(
self._client, self.config, self._serialize, self._deserialize)
self.virtual_machine_images = VirtualMachineImagesOperations(
self._client, self.config, self._serialize, self._deserialize)
self.usage = UsageOperations(
self._client, self.config, self._serialize, self._deserialize)
self.virtual_machine_sizes = VirtualMachineSizesOperations(
self._client, self.config, self._serialize, self._deserialize)
self.images = ImagesOperations(
self._client, self.config, self._serialize, self._deserialize)
self.virtual_machines = VirtualMachinesOperations(
self._client, self.config, self._serialize, self._deserialize)
self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(
self._client, self.config, self._serialize, self._deserialize)
self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(
self._client, self.config, self._serialize, self._deserialize)
self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(
self._client, self.config, self._serialize, self._deserialize)
self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(
self._client, self.config, self._serialize, self._deserialize)
self.log_analytics = LogAnalyticsOperations(
self._client, self.config, self._serialize, self._deserialize)
self.galleries = GalleriesOperations(
self._client, self.config, self._serialize, self._deserialize)
self.gallery_images = GalleryImagesOperations(
Expand Down
Loading