Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Generated from 4591722b279f1148b3c6b3e2307a07f4843b4929
added long-running op
update accordingly
  • Loading branch information
AutorestCI committed Sep 13, 2018
commit a6b63425cd77cd427ae2051056f5c321d33090dd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import uuid
from msrest.pipeline import ClientRawResponse
from msrest.polling import LROPoller, NoPolling
from msrestazure.polling.arm_polling import ARMPolling

from .. import models

Expand Down Expand Up @@ -177,33 +179,9 @@ def get(
return deserialized
get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes/{computeName}'}

def create_or_update(
self, resource_group_name, workspace_name, compute_name, parameters, custom_headers=None, raw=False, **operation_config):
"""Creates or updates compute. This call will overwrite a compute if it
exists. This is a nonrecoverable operation. If your intent is to create
a new compute, do a GET first to verify that it does not exist yet.

:param resource_group_name: Name of the resource group in which
workspace is located.
:type resource_group_name: str
:param workspace_name: Name of Azure Machine Learning workspace.
:type workspace_name: str
:param compute_name: Name of the Azure Machine Learning compute.
:type compute_name: str
:param parameters: Payload with Machine Learning compute definition.
:type parameters:
~azure.mgmt.machinelearningservices.models.ComputeResource
: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<msrest:optionsforoperations>`.
:return: ComputeResource or ClientRawResponse if raw=true
:rtype: ~azure.mgmt.machinelearningservices.models.ComputeResource or
~msrest.pipeline.ClientRawResponse
:raises:
:class:`MachineLearningServiceErrorException<azure.mgmt.machinelearningservices.models.MachineLearningServiceErrorException>`
"""
def _create_or_update_initial(
self, resource_group_name, workspace_name, compute_name, parameters, custom_headers=None, raw=False, **operation_config):
# Construct URL
url = self.create_or_update.metadata['url']
path_format_arguments = {
Expand Down Expand Up @@ -236,12 +214,17 @@ def create_or_update(
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 [201]:
if response.status_code not in [200, 201]:
raise models.MachineLearningServiceErrorException(self._deserialize, response)

deserialized = None
header_dict = {}

if response.status_code == 200:
deserialized = self._deserialize('ComputeResource', response)
header_dict = {
'Azure-AsyncOperation': 'str',
}
if response.status_code == 201:
deserialized = self._deserialize('ComputeResource', response)
header_dict = {
Expand All @@ -254,11 +237,12 @@ def create_or_update(
return client_raw_response

return deserialized
create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes/{computeName}'}

def delete(
self, resource_group_name, workspace_name, compute_name, custom_headers=None, raw=False, **operation_config):
"""Deletes specified Machine Learning compute.
def create_or_update(
self, resource_group_name, workspace_name, compute_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config):
"""Creates or updates compute. This call will overwrite a compute if it
exists. This is a nonrecoverable operation. If your intent is to create
a new compute, do a GET first to verify that it does not exist yet.

:param resource_group_name: Name of the resource group in which
workspace is located.
Expand All @@ -267,16 +251,58 @@ def delete(
:type workspace_name: str
:param compute_name: Name of the Azure Machine Learning compute.
:type compute_name: str
:param parameters: Payload with Machine Learning compute definition.
:type parameters:
~azure.mgmt.machinelearningservices.models.ComputeResource
: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<msrest:optionsforoperations>`.
:return: None or ClientRawResponse if raw=true
:rtype: None or ~msrest.pipeline.ClientRawResponse
: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 ComputeResource or
ClientRawResponse<ComputeResource> if raw==True
:rtype:
~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.machinelearningservices.models.ComputeResource]
or
~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.machinelearningservices.models.ComputeResource]]
:raises:
:class:`MachineLearningServiceErrorException<azure.mgmt.machinelearningservices.models.MachineLearningServiceErrorException>`
"""
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
workspace_name=workspace_name,
compute_name=compute_name,
parameters=parameters,
custom_headers=custom_headers,
raw=True,
**operation_config
)

def get_long_running_output(response):
header_dict = {
'Azure-AsyncOperation': 'str',
}
deserialized = self._deserialize('ComputeResource', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
client_raw_response.add_headers(header_dict)
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)
create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes/{computeName}'}


def _delete_initial(
self, resource_group_name, workspace_name, compute_name, custom_headers=None, raw=False, **operation_config):
# Construct URL
url = self.delete.metadata['url']
path_format_arguments = {
Expand Down Expand Up @@ -304,21 +330,21 @@ def delete(
request = self._client.delete(url, query_parameters, header_parameters)
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [202]:
if response.status_code not in [200, 202]:
raise models.MachineLearningServiceErrorException(self._deserialize, response)

if raw:
client_raw_response = ClientRawResponse(None, response)
client_raw_response.add_headers({
header_dict = {
'Azure-AsyncOperation': 'str',
'Location': 'str',
})
}
client_raw_response.add_headers(header_dict)
return client_raw_response
delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes/{computeName}'}

def system_update(
self, resource_group_name, workspace_name, compute_name, custom_headers=None, raw=False, **operation_config):
"""System Update On Machine Learning compute.
def delete(
self, resource_group_name, workspace_name, compute_name, custom_headers=None, raw=False, polling=True, **operation_config):
"""Deletes specified Machine Learning compute.

:param resource_group_name: Name of the resource group in which
workspace is located.
Expand All @@ -328,15 +354,47 @@ def system_update(
:param compute_name: Name of the Azure Machine Learning compute.
:type compute_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<msrest:optionsforoperations>`.
:return: None or ClientRawResponse if raw=true
:rtype: None or ~msrest.pipeline.ClientRawResponse
: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 None or
ClientRawResponse<None> if raw==True
:rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
:raises:
:class:`MachineLearningServiceErrorException<azure.mgmt.machinelearningservices.models.MachineLearningServiceErrorException>`
"""
raw_result = self._delete_initial(
resource_group_name=resource_group_name,
workspace_name=workspace_name,
compute_name=compute_name,
custom_headers=custom_headers,
raw=True,
**operation_config
)

def get_long_running_output(response):
if raw:
client_raw_response = ClientRawResponse(None, response)
client_raw_response.add_headers({
'Azure-AsyncOperation': 'str',
'Location': 'str',
})
return client_raw_response

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)
delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes/{computeName}'}


def _system_update_initial(
self, resource_group_name, workspace_name, compute_name, custom_headers=None, raw=False, **operation_config):
# Construct URL
url = self.system_update.metadata['url']
path_format_arguments = {
Expand Down Expand Up @@ -364,16 +422,66 @@ def system_update(
request = self._client.post(url, query_parameters, header_parameters)
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [202]:
if response.status_code not in [200, 202]:
raise models.MachineLearningServiceErrorException(self._deserialize, response)

if raw:
client_raw_response = ClientRawResponse(None, response)
client_raw_response.add_headers({
header_dict = {
'Azure-AsyncOperation': 'str',
'Location': 'str',
})
}
client_raw_response.add_headers(header_dict)
return client_raw_response

def system_update(
self, resource_group_name, workspace_name, compute_name, custom_headers=None, raw=False, polling=True, **operation_config):
"""System Update On Machine Learning compute.

:param resource_group_name: Name of the resource group in which
workspace is located.
:type resource_group_name: str
:param workspace_name: Name of Azure Machine Learning workspace.
:type workspace_name: str
:param compute_name: Name of the Azure Machine Learning compute.
:type compute_name: str
: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 None or
ClientRawResponse<None> if raw==True
:rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
:raises:
:class:`MachineLearningServiceErrorException<azure.mgmt.machinelearningservices.models.MachineLearningServiceErrorException>`
"""
raw_result = self._system_update_initial(
resource_group_name=resource_group_name,
workspace_name=workspace_name,
compute_name=compute_name,
custom_headers=custom_headers,
raw=True,
**operation_config
)

def get_long_running_output(response):
if raw:
client_raw_response = ClientRawResponse(None, response)
client_raw_response.add_headers({
'Azure-AsyncOperation': 'str',
'Location': 'str',
})
return client_raw_response

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)
system_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes/{computeName}'}

def list_keys(
Expand Down