1package machinelearningservices
2
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// Licensed under the MIT License. See License.txt in the project root for license information.
5//
6// Code generated by Microsoft (R) AutoRest Code Generator.
7// Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
9import (
10	"context"
11	"github.com/Azure/go-autorest/autorest"
12	"github.com/Azure/go-autorest/autorest/azure"
13	"github.com/Azure/go-autorest/tracing"
14	"net/http"
15)
16
17// MachineLearningComputeClient is the these APIs allow end users to operate on Azure Machine Learning Workspace
18// resources.
19type MachineLearningComputeClient struct {
20	BaseClient
21}
22
23// NewMachineLearningComputeClient creates an instance of the MachineLearningComputeClient client.
24func NewMachineLearningComputeClient(subscriptionID string) MachineLearningComputeClient {
25	return NewMachineLearningComputeClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewMachineLearningComputeClientWithBaseURI creates an instance of the MachineLearningComputeClient client using a
29// custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds,
30// Azure stack).
31func NewMachineLearningComputeClientWithBaseURI(baseURI string, subscriptionID string) MachineLearningComputeClient {
32	return MachineLearningComputeClient{NewWithBaseURI(baseURI, subscriptionID)}
33}
34
35// CreateOrUpdate creates or updates compute. This call will overwrite a compute if it exists. This is a nonrecoverable
36// operation. If your intent is to create a new compute, do a GET first to verify that it does not exist yet.
37// Parameters:
38// resourceGroupName - name of the resource group in which workspace is located.
39// workspaceName - name of Azure Machine Learning workspace.
40// computeName - name of the Azure Machine Learning compute.
41// parameters - payload with Machine Learning compute definition.
42func (client MachineLearningComputeClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, computeName string, parameters ComputeResource) (result MachineLearningComputeCreateOrUpdateFuture, err error) {
43	if tracing.IsEnabled() {
44		ctx = tracing.StartSpan(ctx, fqdn+"/MachineLearningComputeClient.CreateOrUpdate")
45		defer func() {
46			sc := -1
47			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
48				sc = result.FutureAPI.Response().StatusCode
49			}
50			tracing.EndSpan(ctx, sc, err)
51		}()
52	}
53	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, workspaceName, computeName, parameters)
54	if err != nil {
55		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "CreateOrUpdate", nil, "Failure preparing request")
56		return
57	}
58
59	result, err = client.CreateOrUpdateSender(req)
60	if err != nil {
61		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "CreateOrUpdate", nil, "Failure sending request")
62		return
63	}
64
65	return
66}
67
68// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
69func (client MachineLearningComputeClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, workspaceName string, computeName string, parameters ComputeResource) (*http.Request, error) {
70	pathParameters := map[string]interface{}{
71		"computeName":       autorest.Encode("path", computeName),
72		"resourceGroupName": autorest.Encode("path", resourceGroupName),
73		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
74		"workspaceName":     autorest.Encode("path", workspaceName),
75	}
76
77	const APIVersion = "2020-03-01"
78	queryParameters := map[string]interface{}{
79		"api-version": APIVersion,
80	}
81
82	preparer := autorest.CreatePreparer(
83		autorest.AsContentType("application/json; charset=utf-8"),
84		autorest.AsPut(),
85		autorest.WithBaseURL(client.BaseURI),
86		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes/{computeName}", pathParameters),
87		autorest.WithJSON(parameters),
88		autorest.WithQueryParameters(queryParameters))
89	return preparer.Prepare((&http.Request{}).WithContext(ctx))
90}
91
92// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
93// http.Response Body if it receives an error.
94func (client MachineLearningComputeClient) CreateOrUpdateSender(req *http.Request) (future MachineLearningComputeCreateOrUpdateFuture, err error) {
95	var resp *http.Response
96	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
97	if err != nil {
98		return
99	}
100	var azf azure.Future
101	azf, err = azure.NewFutureFromResponse(resp)
102	future.FutureAPI = &azf
103	future.Result = future.result
104	return
105}
106
107// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
108// closes the http.Response Body.
109func (client MachineLearningComputeClient) CreateOrUpdateResponder(resp *http.Response) (result ComputeResource, err error) {
110	err = autorest.Respond(
111		resp,
112		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
113		autorest.ByUnmarshallingJSON(&result),
114		autorest.ByClosing())
115	result.Response = autorest.Response{Response: resp}
116	return
117}
118
119// Delete deletes specified Machine Learning compute.
120// Parameters:
121// resourceGroupName - name of the resource group in which workspace is located.
122// workspaceName - name of Azure Machine Learning workspace.
123// computeName - name of the Azure Machine Learning compute.
124// underlyingResourceAction - delete the underlying compute if 'Delete', or detach the underlying compute from
125// workspace if 'Detach'.
126func (client MachineLearningComputeClient) Delete(ctx context.Context, resourceGroupName string, workspaceName string, computeName string, underlyingResourceAction UnderlyingResourceAction) (result MachineLearningComputeDeleteFuture, err error) {
127	if tracing.IsEnabled() {
128		ctx = tracing.StartSpan(ctx, fqdn+"/MachineLearningComputeClient.Delete")
129		defer func() {
130			sc := -1
131			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
132				sc = result.FutureAPI.Response().StatusCode
133			}
134			tracing.EndSpan(ctx, sc, err)
135		}()
136	}
137	req, err := client.DeletePreparer(ctx, resourceGroupName, workspaceName, computeName, underlyingResourceAction)
138	if err != nil {
139		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "Delete", nil, "Failure preparing request")
140		return
141	}
142
143	result, err = client.DeleteSender(req)
144	if err != nil {
145		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "Delete", nil, "Failure sending request")
146		return
147	}
148
149	return
150}
151
152// DeletePreparer prepares the Delete request.
153func (client MachineLearningComputeClient) DeletePreparer(ctx context.Context, resourceGroupName string, workspaceName string, computeName string, underlyingResourceAction UnderlyingResourceAction) (*http.Request, error) {
154	pathParameters := map[string]interface{}{
155		"computeName":       autorest.Encode("path", computeName),
156		"resourceGroupName": autorest.Encode("path", resourceGroupName),
157		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
158		"workspaceName":     autorest.Encode("path", workspaceName),
159	}
160
161	const APIVersion = "2020-03-01"
162	queryParameters := map[string]interface{}{
163		"api-version":              APIVersion,
164		"underlyingResourceAction": autorest.Encode("query", underlyingResourceAction),
165	}
166
167	preparer := autorest.CreatePreparer(
168		autorest.AsDelete(),
169		autorest.WithBaseURL(client.BaseURI),
170		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes/{computeName}", pathParameters),
171		autorest.WithQueryParameters(queryParameters))
172	return preparer.Prepare((&http.Request{}).WithContext(ctx))
173}
174
175// DeleteSender sends the Delete request. The method will close the
176// http.Response Body if it receives an error.
177func (client MachineLearningComputeClient) DeleteSender(req *http.Request) (future MachineLearningComputeDeleteFuture, err error) {
178	var resp *http.Response
179	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
180	if err != nil {
181		return
182	}
183	var azf azure.Future
184	azf, err = azure.NewFutureFromResponse(resp)
185	future.FutureAPI = &azf
186	future.Result = future.result
187	return
188}
189
190// DeleteResponder handles the response to the Delete request. The method always
191// closes the http.Response Body.
192func (client MachineLearningComputeClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
193	err = autorest.Respond(
194		resp,
195		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
196		autorest.ByClosing())
197	result.Response = resp
198	return
199}
200
201// Get gets compute definition by its name. Any secrets (storage keys, service credentials, etc) are not returned - use
202// 'keys' nested resource to get them.
203// Parameters:
204// resourceGroupName - name of the resource group in which workspace is located.
205// workspaceName - name of Azure Machine Learning workspace.
206// computeName - name of the Azure Machine Learning compute.
207func (client MachineLearningComputeClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, computeName string) (result ComputeResource, err error) {
208	if tracing.IsEnabled() {
209		ctx = tracing.StartSpan(ctx, fqdn+"/MachineLearningComputeClient.Get")
210		defer func() {
211			sc := -1
212			if result.Response.Response != nil {
213				sc = result.Response.Response.StatusCode
214			}
215			tracing.EndSpan(ctx, sc, err)
216		}()
217	}
218	req, err := client.GetPreparer(ctx, resourceGroupName, workspaceName, computeName)
219	if err != nil {
220		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "Get", nil, "Failure preparing request")
221		return
222	}
223
224	resp, err := client.GetSender(req)
225	if err != nil {
226		result.Response = autorest.Response{Response: resp}
227		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "Get", resp, "Failure sending request")
228		return
229	}
230
231	result, err = client.GetResponder(resp)
232	if err != nil {
233		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "Get", resp, "Failure responding to request")
234		return
235	}
236
237	return
238}
239
240// GetPreparer prepares the Get request.
241func (client MachineLearningComputeClient) GetPreparer(ctx context.Context, resourceGroupName string, workspaceName string, computeName string) (*http.Request, error) {
242	pathParameters := map[string]interface{}{
243		"computeName":       autorest.Encode("path", computeName),
244		"resourceGroupName": autorest.Encode("path", resourceGroupName),
245		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
246		"workspaceName":     autorest.Encode("path", workspaceName),
247	}
248
249	const APIVersion = "2020-03-01"
250	queryParameters := map[string]interface{}{
251		"api-version": APIVersion,
252	}
253
254	preparer := autorest.CreatePreparer(
255		autorest.AsGet(),
256		autorest.WithBaseURL(client.BaseURI),
257		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes/{computeName}", pathParameters),
258		autorest.WithQueryParameters(queryParameters))
259	return preparer.Prepare((&http.Request{}).WithContext(ctx))
260}
261
262// GetSender sends the Get request. The method will close the
263// http.Response Body if it receives an error.
264func (client MachineLearningComputeClient) GetSender(req *http.Request) (*http.Response, error) {
265	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
266}
267
268// GetResponder handles the response to the Get request. The method always
269// closes the http.Response Body.
270func (client MachineLearningComputeClient) GetResponder(resp *http.Response) (result ComputeResource, err error) {
271	err = autorest.Respond(
272		resp,
273		azure.WithErrorUnlessStatusCode(http.StatusOK),
274		autorest.ByUnmarshallingJSON(&result),
275		autorest.ByClosing())
276	result.Response = autorest.Response{Response: resp}
277	return
278}
279
280// ListByWorkspace gets computes in specified workspace.
281// Parameters:
282// resourceGroupName - name of the resource group in which workspace is located.
283// workspaceName - name of Azure Machine Learning workspace.
284// skiptoken - continuation token for pagination.
285func (client MachineLearningComputeClient) ListByWorkspace(ctx context.Context, resourceGroupName string, workspaceName string, skiptoken string) (result PaginatedComputeResourcesListPage, err error) {
286	if tracing.IsEnabled() {
287		ctx = tracing.StartSpan(ctx, fqdn+"/MachineLearningComputeClient.ListByWorkspace")
288		defer func() {
289			sc := -1
290			if result.pcrl.Response.Response != nil {
291				sc = result.pcrl.Response.Response.StatusCode
292			}
293			tracing.EndSpan(ctx, sc, err)
294		}()
295	}
296	result.fn = client.listByWorkspaceNextResults
297	req, err := client.ListByWorkspacePreparer(ctx, resourceGroupName, workspaceName, skiptoken)
298	if err != nil {
299		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "ListByWorkspace", nil, "Failure preparing request")
300		return
301	}
302
303	resp, err := client.ListByWorkspaceSender(req)
304	if err != nil {
305		result.pcrl.Response = autorest.Response{Response: resp}
306		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "ListByWorkspace", resp, "Failure sending request")
307		return
308	}
309
310	result.pcrl, err = client.ListByWorkspaceResponder(resp)
311	if err != nil {
312		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "ListByWorkspace", resp, "Failure responding to request")
313		return
314	}
315	if result.pcrl.hasNextLink() && result.pcrl.IsEmpty() {
316		err = result.NextWithContext(ctx)
317		return
318	}
319
320	return
321}
322
323// ListByWorkspacePreparer prepares the ListByWorkspace request.
324func (client MachineLearningComputeClient) ListByWorkspacePreparer(ctx context.Context, resourceGroupName string, workspaceName string, skiptoken string) (*http.Request, error) {
325	pathParameters := map[string]interface{}{
326		"resourceGroupName": autorest.Encode("path", resourceGroupName),
327		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
328		"workspaceName":     autorest.Encode("path", workspaceName),
329	}
330
331	const APIVersion = "2020-03-01"
332	queryParameters := map[string]interface{}{
333		"api-version": APIVersion,
334	}
335	if len(skiptoken) > 0 {
336		queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken)
337	}
338
339	preparer := autorest.CreatePreparer(
340		autorest.AsGet(),
341		autorest.WithBaseURL(client.BaseURI),
342		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes", pathParameters),
343		autorest.WithQueryParameters(queryParameters))
344	return preparer.Prepare((&http.Request{}).WithContext(ctx))
345}
346
347// ListByWorkspaceSender sends the ListByWorkspace request. The method will close the
348// http.Response Body if it receives an error.
349func (client MachineLearningComputeClient) ListByWorkspaceSender(req *http.Request) (*http.Response, error) {
350	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
351}
352
353// ListByWorkspaceResponder handles the response to the ListByWorkspace request. The method always
354// closes the http.Response Body.
355func (client MachineLearningComputeClient) ListByWorkspaceResponder(resp *http.Response) (result PaginatedComputeResourcesList, err error) {
356	err = autorest.Respond(
357		resp,
358		azure.WithErrorUnlessStatusCode(http.StatusOK),
359		autorest.ByUnmarshallingJSON(&result),
360		autorest.ByClosing())
361	result.Response = autorest.Response{Response: resp}
362	return
363}
364
365// listByWorkspaceNextResults retrieves the next set of results, if any.
366func (client MachineLearningComputeClient) listByWorkspaceNextResults(ctx context.Context, lastResults PaginatedComputeResourcesList) (result PaginatedComputeResourcesList, err error) {
367	req, err := lastResults.paginatedComputeResourcesListPreparer(ctx)
368	if err != nil {
369		return result, autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "listByWorkspaceNextResults", nil, "Failure preparing next results request")
370	}
371	if req == nil {
372		return
373	}
374	resp, err := client.ListByWorkspaceSender(req)
375	if err != nil {
376		result.Response = autorest.Response{Response: resp}
377		return result, autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "listByWorkspaceNextResults", resp, "Failure sending next results request")
378	}
379	result, err = client.ListByWorkspaceResponder(resp)
380	if err != nil {
381		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "listByWorkspaceNextResults", resp, "Failure responding to next results request")
382	}
383	return
384}
385
386// ListByWorkspaceComplete enumerates all values, automatically crossing page boundaries as required.
387func (client MachineLearningComputeClient) ListByWorkspaceComplete(ctx context.Context, resourceGroupName string, workspaceName string, skiptoken string) (result PaginatedComputeResourcesListIterator, err error) {
388	if tracing.IsEnabled() {
389		ctx = tracing.StartSpan(ctx, fqdn+"/MachineLearningComputeClient.ListByWorkspace")
390		defer func() {
391			sc := -1
392			if result.Response().Response.Response != nil {
393				sc = result.page.Response().Response.Response.StatusCode
394			}
395			tracing.EndSpan(ctx, sc, err)
396		}()
397	}
398	result.page, err = client.ListByWorkspace(ctx, resourceGroupName, workspaceName, skiptoken)
399	return
400}
401
402// ListKeys gets secrets related to Machine Learning compute (storage keys, service credentials, etc).
403// Parameters:
404// resourceGroupName - name of the resource group in which workspace is located.
405// workspaceName - name of Azure Machine Learning workspace.
406// computeName - name of the Azure Machine Learning compute.
407func (client MachineLearningComputeClient) ListKeys(ctx context.Context, resourceGroupName string, workspaceName string, computeName string) (result ComputeSecretsModel, err error) {
408	if tracing.IsEnabled() {
409		ctx = tracing.StartSpan(ctx, fqdn+"/MachineLearningComputeClient.ListKeys")
410		defer func() {
411			sc := -1
412			if result.Response.Response != nil {
413				sc = result.Response.Response.StatusCode
414			}
415			tracing.EndSpan(ctx, sc, err)
416		}()
417	}
418	req, err := client.ListKeysPreparer(ctx, resourceGroupName, workspaceName, computeName)
419	if err != nil {
420		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "ListKeys", nil, "Failure preparing request")
421		return
422	}
423
424	resp, err := client.ListKeysSender(req)
425	if err != nil {
426		result.Response = autorest.Response{Response: resp}
427		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "ListKeys", resp, "Failure sending request")
428		return
429	}
430
431	result, err = client.ListKeysResponder(resp)
432	if err != nil {
433		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "ListKeys", resp, "Failure responding to request")
434		return
435	}
436
437	return
438}
439
440// ListKeysPreparer prepares the ListKeys request.
441func (client MachineLearningComputeClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, workspaceName string, computeName string) (*http.Request, error) {
442	pathParameters := map[string]interface{}{
443		"computeName":       autorest.Encode("path", computeName),
444		"resourceGroupName": autorest.Encode("path", resourceGroupName),
445		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
446		"workspaceName":     autorest.Encode("path", workspaceName),
447	}
448
449	const APIVersion = "2020-03-01"
450	queryParameters := map[string]interface{}{
451		"api-version": APIVersion,
452	}
453
454	preparer := autorest.CreatePreparer(
455		autorest.AsPost(),
456		autorest.WithBaseURL(client.BaseURI),
457		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes/{computeName}/listKeys", pathParameters),
458		autorest.WithQueryParameters(queryParameters))
459	return preparer.Prepare((&http.Request{}).WithContext(ctx))
460}
461
462// ListKeysSender sends the ListKeys request. The method will close the
463// http.Response Body if it receives an error.
464func (client MachineLearningComputeClient) ListKeysSender(req *http.Request) (*http.Response, error) {
465	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
466}
467
468// ListKeysResponder handles the response to the ListKeys request. The method always
469// closes the http.Response Body.
470func (client MachineLearningComputeClient) ListKeysResponder(resp *http.Response) (result ComputeSecretsModel, err error) {
471	err = autorest.Respond(
472		resp,
473		azure.WithErrorUnlessStatusCode(http.StatusOK),
474		autorest.ByUnmarshallingJSON(&result),
475		autorest.ByClosing())
476	result.Response = autorest.Response{Response: resp}
477	return
478}
479
480// ListNodes get the details (e.g IP address, port etc) of all the compute nodes in the compute.
481// Parameters:
482// resourceGroupName - name of the resource group in which workspace is located.
483// workspaceName - name of Azure Machine Learning workspace.
484// computeName - name of the Azure Machine Learning compute.
485func (client MachineLearningComputeClient) ListNodes(ctx context.Context, resourceGroupName string, workspaceName string, computeName string) (result AmlComputeNodesInformation, err error) {
486	if tracing.IsEnabled() {
487		ctx = tracing.StartSpan(ctx, fqdn+"/MachineLearningComputeClient.ListNodes")
488		defer func() {
489			sc := -1
490			if result.Response.Response != nil {
491				sc = result.Response.Response.StatusCode
492			}
493			tracing.EndSpan(ctx, sc, err)
494		}()
495	}
496	req, err := client.ListNodesPreparer(ctx, resourceGroupName, workspaceName, computeName)
497	if err != nil {
498		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "ListNodes", nil, "Failure preparing request")
499		return
500	}
501
502	resp, err := client.ListNodesSender(req)
503	if err != nil {
504		result.Response = autorest.Response{Response: resp}
505		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "ListNodes", resp, "Failure sending request")
506		return
507	}
508
509	result, err = client.ListNodesResponder(resp)
510	if err != nil {
511		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "ListNodes", resp, "Failure responding to request")
512		return
513	}
514
515	return
516}
517
518// ListNodesPreparer prepares the ListNodes request.
519func (client MachineLearningComputeClient) ListNodesPreparer(ctx context.Context, resourceGroupName string, workspaceName string, computeName string) (*http.Request, error) {
520	pathParameters := map[string]interface{}{
521		"computeName":       autorest.Encode("path", computeName),
522		"resourceGroupName": autorest.Encode("path", resourceGroupName),
523		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
524		"workspaceName":     autorest.Encode("path", workspaceName),
525	}
526
527	const APIVersion = "2020-03-01"
528	queryParameters := map[string]interface{}{
529		"api-version": APIVersion,
530	}
531
532	preparer := autorest.CreatePreparer(
533		autorest.AsPost(),
534		autorest.WithBaseURL(client.BaseURI),
535		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes/{computeName}/listNodes", pathParameters),
536		autorest.WithQueryParameters(queryParameters))
537	return preparer.Prepare((&http.Request{}).WithContext(ctx))
538}
539
540// ListNodesSender sends the ListNodes request. The method will close the
541// http.Response Body if it receives an error.
542func (client MachineLearningComputeClient) ListNodesSender(req *http.Request) (*http.Response, error) {
543	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
544}
545
546// ListNodesResponder handles the response to the ListNodes request. The method always
547// closes the http.Response Body.
548func (client MachineLearningComputeClient) ListNodesResponder(resp *http.Response) (result AmlComputeNodesInformation, err error) {
549	err = autorest.Respond(
550		resp,
551		azure.WithErrorUnlessStatusCode(http.StatusOK),
552		autorest.ByUnmarshallingJSON(&result),
553		autorest.ByClosing())
554	result.Response = autorest.Response{Response: resp}
555	return
556}
557
558// Update updates properties of a compute. This call will overwrite a compute if it exists. This is a nonrecoverable
559// operation.
560// Parameters:
561// resourceGroupName - name of the resource group in which workspace is located.
562// workspaceName - name of Azure Machine Learning workspace.
563// computeName - name of the Azure Machine Learning compute.
564// parameters - additional parameters for cluster update.
565func (client MachineLearningComputeClient) Update(ctx context.Context, resourceGroupName string, workspaceName string, computeName string, parameters ClusterUpdateParameters) (result MachineLearningComputeUpdateFuture, err error) {
566	if tracing.IsEnabled() {
567		ctx = tracing.StartSpan(ctx, fqdn+"/MachineLearningComputeClient.Update")
568		defer func() {
569			sc := -1
570			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
571				sc = result.FutureAPI.Response().StatusCode
572			}
573			tracing.EndSpan(ctx, sc, err)
574		}()
575	}
576	req, err := client.UpdatePreparer(ctx, resourceGroupName, workspaceName, computeName, parameters)
577	if err != nil {
578		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "Update", nil, "Failure preparing request")
579		return
580	}
581
582	result, err = client.UpdateSender(req)
583	if err != nil {
584		err = autorest.NewErrorWithError(err, "machinelearningservices.MachineLearningComputeClient", "Update", nil, "Failure sending request")
585		return
586	}
587
588	return
589}
590
591// UpdatePreparer prepares the Update request.
592func (client MachineLearningComputeClient) UpdatePreparer(ctx context.Context, resourceGroupName string, workspaceName string, computeName string, parameters ClusterUpdateParameters) (*http.Request, error) {
593	pathParameters := map[string]interface{}{
594		"computeName":       autorest.Encode("path", computeName),
595		"resourceGroupName": autorest.Encode("path", resourceGroupName),
596		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
597		"workspaceName":     autorest.Encode("path", workspaceName),
598	}
599
600	const APIVersion = "2020-03-01"
601	queryParameters := map[string]interface{}{
602		"api-version": APIVersion,
603	}
604
605	preparer := autorest.CreatePreparer(
606		autorest.AsContentType("application/json; charset=utf-8"),
607		autorest.AsPatch(),
608		autorest.WithBaseURL(client.BaseURI),
609		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/computes/{computeName}", pathParameters),
610		autorest.WithJSON(parameters),
611		autorest.WithQueryParameters(queryParameters))
612	return preparer.Prepare((&http.Request{}).WithContext(ctx))
613}
614
615// UpdateSender sends the Update request. The method will close the
616// http.Response Body if it receives an error.
617func (client MachineLearningComputeClient) UpdateSender(req *http.Request) (future MachineLearningComputeUpdateFuture, err error) {
618	var resp *http.Response
619	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
620	if err != nil {
621		return
622	}
623	var azf azure.Future
624	azf, err = azure.NewFutureFromResponse(resp)
625	future.FutureAPI = &azf
626	future.Result = future.result
627	return
628}
629
630// UpdateResponder handles the response to the Update request. The method always
631// closes the http.Response Body.
632func (client MachineLearningComputeClient) UpdateResponder(resp *http.Response) (result ComputeResource, err error) {
633	err = autorest.Respond(
634		resp,
635		azure.WithErrorUnlessStatusCode(http.StatusOK),
636		autorest.ByUnmarshallingJSON(&result),
637		autorest.ByClosing())
638	result.Response = autorest.Response{Response: resp}
639	return
640}
641