mirror of
https://github.com/rclone/rclone.git
synced 2024-12-04 14:26:42 +01:00
1046 lines
43 KiB
Go
Executable File
1046 lines
43 KiB
Go
Executable File
package devtestlabs
|
|
|
|
// Copyright (c) Microsoft and contributors. All rights reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
//
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
//
|
|
// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
|
|
// Changes may cause incorrect behavior and will be lost if the code is
|
|
// regenerated.
|
|
|
|
import (
|
|
"github.com/Azure/go-autorest/autorest"
|
|
"github.com/Azure/go-autorest/autorest/azure"
|
|
"github.com/Azure/go-autorest/autorest/validation"
|
|
"net/http"
|
|
)
|
|
|
|
// VirtualMachinesClient is the the DevTest Labs Client.
|
|
type VirtualMachinesClient struct {
|
|
ManagementClient
|
|
}
|
|
|
|
// NewVirtualMachinesClient creates an instance of the VirtualMachinesClient
|
|
// client.
|
|
func NewVirtualMachinesClient(subscriptionID string) VirtualMachinesClient {
|
|
return NewVirtualMachinesClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
|
}
|
|
|
|
// NewVirtualMachinesClientWithBaseURI creates an instance of the
|
|
// VirtualMachinesClient client.
|
|
func NewVirtualMachinesClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachinesClient {
|
|
return VirtualMachinesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
|
}
|
|
|
|
// AddDataDisk attach a new or existing data disk to virtual machine. This
|
|
// operation can take a while to complete. This method may poll for completion.
|
|
// Polling can be canceled by passing the cancel channel argument. The channel
|
|
// will be used to cancel polling and any outstanding HTTP requests.
|
|
//
|
|
// resourceGroupName is the name of the resource group. labName is the name of
|
|
// the lab. name is the name of the virtual machine. dataDiskProperties is
|
|
// request body for adding a new or existing data disk to a virtual machine.
|
|
func (client VirtualMachinesClient) AddDataDisk(resourceGroupName string, labName string, name string, dataDiskProperties DataDiskProperties, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
|
|
resultChan := make(chan autorest.Response, 1)
|
|
errChan := make(chan error, 1)
|
|
go func() {
|
|
var err error
|
|
var result autorest.Response
|
|
defer func() {
|
|
resultChan <- result
|
|
errChan <- err
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
req, err := client.AddDataDiskPreparer(resourceGroupName, labName, name, dataDiskProperties, cancel)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "AddDataDisk", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.AddDataDiskSender(req)
|
|
if err != nil {
|
|
result.Response = resp
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "AddDataDisk", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.AddDataDiskResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "AddDataDisk", resp, "Failure responding to request")
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// AddDataDiskPreparer prepares the AddDataDisk request.
|
|
func (client VirtualMachinesClient) AddDataDiskPreparer(resourceGroupName string, labName string, name string, dataDiskProperties DataDiskProperties, cancel <-chan struct{}) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"labName": autorest.Encode("path", labName),
|
|
"name": autorest.Encode("path", name),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2016-05-15"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsJSON(),
|
|
autorest.AsPost(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/addDataDisk", pathParameters),
|
|
autorest.WithJSON(dataDiskProperties),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{Cancel: cancel})
|
|
}
|
|
|
|
// AddDataDiskSender sends the AddDataDisk request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client VirtualMachinesClient) AddDataDiskSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoPollForAsynchronous(client.PollingDelay))
|
|
}
|
|
|
|
// AddDataDiskResponder handles the response to the AddDataDisk request. The method always
|
|
// closes the http.Response Body.
|
|
func (client VirtualMachinesClient) AddDataDiskResponder(resp *http.Response) (result autorest.Response, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
|
autorest.ByClosing())
|
|
result.Response = resp
|
|
return
|
|
}
|
|
|
|
// ApplyArtifacts apply artifacts to virtual machine. This operation can take a
|
|
// while to complete. This method may poll for completion. Polling can be
|
|
// canceled by passing the cancel channel argument. The channel will be used to
|
|
// cancel polling and any outstanding HTTP requests.
|
|
//
|
|
// resourceGroupName is the name of the resource group. labName is the name of
|
|
// the lab. name is the name of the virtual machine. applyArtifactsRequest is
|
|
// request body for applying artifacts to a virtual machine.
|
|
func (client VirtualMachinesClient) ApplyArtifacts(resourceGroupName string, labName string, name string, applyArtifactsRequest ApplyArtifactsRequest, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
|
|
resultChan := make(chan autorest.Response, 1)
|
|
errChan := make(chan error, 1)
|
|
go func() {
|
|
var err error
|
|
var result autorest.Response
|
|
defer func() {
|
|
resultChan <- result
|
|
errChan <- err
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
req, err := client.ApplyArtifactsPreparer(resourceGroupName, labName, name, applyArtifactsRequest, cancel)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "ApplyArtifacts", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.ApplyArtifactsSender(req)
|
|
if err != nil {
|
|
result.Response = resp
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "ApplyArtifacts", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ApplyArtifactsResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "ApplyArtifacts", resp, "Failure responding to request")
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// ApplyArtifactsPreparer prepares the ApplyArtifacts request.
|
|
func (client VirtualMachinesClient) ApplyArtifactsPreparer(resourceGroupName string, labName string, name string, applyArtifactsRequest ApplyArtifactsRequest, cancel <-chan struct{}) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"labName": autorest.Encode("path", labName),
|
|
"name": autorest.Encode("path", name),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2016-05-15"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsJSON(),
|
|
autorest.AsPost(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/applyArtifacts", pathParameters),
|
|
autorest.WithJSON(applyArtifactsRequest),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{Cancel: cancel})
|
|
}
|
|
|
|
// ApplyArtifactsSender sends the ApplyArtifacts request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client VirtualMachinesClient) ApplyArtifactsSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoPollForAsynchronous(client.PollingDelay))
|
|
}
|
|
|
|
// ApplyArtifactsResponder handles the response to the ApplyArtifacts request. The method always
|
|
// closes the http.Response Body.
|
|
func (client VirtualMachinesClient) ApplyArtifactsResponder(resp *http.Response) (result autorest.Response, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
|
autorest.ByClosing())
|
|
result.Response = resp
|
|
return
|
|
}
|
|
|
|
// Claim take ownership of an existing virtual machine This operation can take
|
|
// a while to complete. This method may poll for completion. Polling can be
|
|
// canceled by passing the cancel channel argument. The channel will be used to
|
|
// cancel polling and any outstanding HTTP requests.
|
|
//
|
|
// resourceGroupName is the name of the resource group. labName is the name of
|
|
// the lab. name is the name of the virtual machine.
|
|
func (client VirtualMachinesClient) Claim(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
|
|
resultChan := make(chan autorest.Response, 1)
|
|
errChan := make(chan error, 1)
|
|
go func() {
|
|
var err error
|
|
var result autorest.Response
|
|
defer func() {
|
|
resultChan <- result
|
|
errChan <- err
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
req, err := client.ClaimPreparer(resourceGroupName, labName, name, cancel)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Claim", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.ClaimSender(req)
|
|
if err != nil {
|
|
result.Response = resp
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Claim", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ClaimResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Claim", resp, "Failure responding to request")
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// ClaimPreparer prepares the Claim request.
|
|
func (client VirtualMachinesClient) ClaimPreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"labName": autorest.Encode("path", labName),
|
|
"name": autorest.Encode("path", name),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2016-05-15"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsPost(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/claim", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{Cancel: cancel})
|
|
}
|
|
|
|
// ClaimSender sends the Claim request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client VirtualMachinesClient) ClaimSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoPollForAsynchronous(client.PollingDelay))
|
|
}
|
|
|
|
// ClaimResponder handles the response to the Claim request. The method always
|
|
// closes the http.Response Body.
|
|
func (client VirtualMachinesClient) ClaimResponder(resp *http.Response) (result autorest.Response, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
|
autorest.ByClosing())
|
|
result.Response = resp
|
|
return
|
|
}
|
|
|
|
// CreateOrUpdate create or replace an existing Virtual machine. This operation
|
|
// can take a while to complete. This method may poll for completion. Polling
|
|
// can be canceled by passing the cancel channel argument. The channel will be
|
|
// used to cancel polling and any outstanding HTTP requests.
|
|
//
|
|
// resourceGroupName is the name of the resource group. labName is the name of
|
|
// the lab. name is the name of the virtual machine. labVirtualMachine is a
|
|
// virtual machine.
|
|
func (client VirtualMachinesClient) CreateOrUpdate(resourceGroupName string, labName string, name string, labVirtualMachine LabVirtualMachine, cancel <-chan struct{}) (<-chan LabVirtualMachine, <-chan error) {
|
|
resultChan := make(chan LabVirtualMachine, 1)
|
|
errChan := make(chan error, 1)
|
|
if err := validation.Validate([]validation.Validation{
|
|
{TargetValue: labVirtualMachine,
|
|
Constraints: []validation.Constraint{{Target: "labVirtualMachine.LabVirtualMachineProperties", Name: validation.Null, Rule: true,
|
|
Chain: []validation.Constraint{{Target: "labVirtualMachine.LabVirtualMachineProperties.ApplicableSchedule", Name: validation.Null, Rule: false,
|
|
Chain: []validation.Constraint{{Target: "labVirtualMachine.LabVirtualMachineProperties.ApplicableSchedule.ApplicableScheduleProperties", Name: validation.Null, Rule: true,
|
|
Chain: []validation.Constraint{{Target: "labVirtualMachine.LabVirtualMachineProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsShutdown", Name: validation.Null, Rule: false,
|
|
Chain: []validation.Constraint{{Target: "labVirtualMachine.LabVirtualMachineProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsShutdown.ScheduleProperties", Name: validation.Null, Rule: true, Chain: nil}}},
|
|
{Target: "labVirtualMachine.LabVirtualMachineProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsStartup", Name: validation.Null, Rule: false,
|
|
Chain: []validation.Constraint{{Target: "labVirtualMachine.LabVirtualMachineProperties.ApplicableSchedule.ApplicableScheduleProperties.LabVmsStartup.ScheduleProperties", Name: validation.Null, Rule: true, Chain: nil}}},
|
|
}},
|
|
}},
|
|
}}}}}); err != nil {
|
|
errChan <- validation.NewErrorWithValidationError(err, "devtestlabs.VirtualMachinesClient", "CreateOrUpdate")
|
|
close(errChan)
|
|
close(resultChan)
|
|
return resultChan, errChan
|
|
}
|
|
|
|
go func() {
|
|
var err error
|
|
var result LabVirtualMachine
|
|
defer func() {
|
|
resultChan <- result
|
|
errChan <- err
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
req, err := client.CreateOrUpdatePreparer(resourceGroupName, labName, name, labVirtualMachine, cancel)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "CreateOrUpdate", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.CreateOrUpdateSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "CreateOrUpdate", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.CreateOrUpdateResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "CreateOrUpdate", resp, "Failure responding to request")
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
|
func (client VirtualMachinesClient) CreateOrUpdatePreparer(resourceGroupName string, labName string, name string, labVirtualMachine LabVirtualMachine, cancel <-chan struct{}) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"labName": autorest.Encode("path", labName),
|
|
"name": autorest.Encode("path", name),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2016-05-15"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsJSON(),
|
|
autorest.AsPut(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}", pathParameters),
|
|
autorest.WithJSON(labVirtualMachine),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{Cancel: cancel})
|
|
}
|
|
|
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client VirtualMachinesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoPollForAsynchronous(client.PollingDelay))
|
|
}
|
|
|
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
|
// closes the http.Response Body.
|
|
func (client VirtualMachinesClient) CreateOrUpdateResponder(resp *http.Response) (result LabVirtualMachine, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// Delete delete virtual machine. This operation can take a while to complete.
|
|
// This method may poll for completion. Polling can be canceled by passing the
|
|
// cancel channel argument. The channel will be used to cancel polling and any
|
|
// outstanding HTTP requests.
|
|
//
|
|
// resourceGroupName is the name of the resource group. labName is the name of
|
|
// the lab. name is the name of the virtual machine.
|
|
func (client VirtualMachinesClient) Delete(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
|
|
resultChan := make(chan autorest.Response, 1)
|
|
errChan := make(chan error, 1)
|
|
go func() {
|
|
var err error
|
|
var result autorest.Response
|
|
defer func() {
|
|
resultChan <- result
|
|
errChan <- err
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
req, err := client.DeletePreparer(resourceGroupName, labName, name, cancel)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Delete", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.DeleteSender(req)
|
|
if err != nil {
|
|
result.Response = resp
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Delete", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.DeleteResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Delete", resp, "Failure responding to request")
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// DeletePreparer prepares the Delete request.
|
|
func (client VirtualMachinesClient) DeletePreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"labName": autorest.Encode("path", labName),
|
|
"name": autorest.Encode("path", name),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2016-05-15"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsDelete(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{Cancel: cancel})
|
|
}
|
|
|
|
// DeleteSender sends the Delete request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client VirtualMachinesClient) DeleteSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoPollForAsynchronous(client.PollingDelay))
|
|
}
|
|
|
|
// DeleteResponder handles the response to the Delete request. The method always
|
|
// closes the http.Response Body.
|
|
func (client VirtualMachinesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
|
|
autorest.ByClosing())
|
|
result.Response = resp
|
|
return
|
|
}
|
|
|
|
// DetachDataDisk detach the specified disk from the virtual machine. This
|
|
// operation can take a while to complete. This method may poll for completion.
|
|
// Polling can be canceled by passing the cancel channel argument. The channel
|
|
// will be used to cancel polling and any outstanding HTTP requests.
|
|
//
|
|
// resourceGroupName is the name of the resource group. labName is the name of
|
|
// the lab. name is the name of the virtual machine. detachDataDiskProperties
|
|
// is request body for detaching data disk from a virtual machine.
|
|
func (client VirtualMachinesClient) DetachDataDisk(resourceGroupName string, labName string, name string, detachDataDiskProperties DetachDataDiskProperties, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
|
|
resultChan := make(chan autorest.Response, 1)
|
|
errChan := make(chan error, 1)
|
|
go func() {
|
|
var err error
|
|
var result autorest.Response
|
|
defer func() {
|
|
resultChan <- result
|
|
errChan <- err
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
req, err := client.DetachDataDiskPreparer(resourceGroupName, labName, name, detachDataDiskProperties, cancel)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "DetachDataDisk", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.DetachDataDiskSender(req)
|
|
if err != nil {
|
|
result.Response = resp
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "DetachDataDisk", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.DetachDataDiskResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "DetachDataDisk", resp, "Failure responding to request")
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// DetachDataDiskPreparer prepares the DetachDataDisk request.
|
|
func (client VirtualMachinesClient) DetachDataDiskPreparer(resourceGroupName string, labName string, name string, detachDataDiskProperties DetachDataDiskProperties, cancel <-chan struct{}) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"labName": autorest.Encode("path", labName),
|
|
"name": autorest.Encode("path", name),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2016-05-15"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsJSON(),
|
|
autorest.AsPost(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/detachDataDisk", pathParameters),
|
|
autorest.WithJSON(detachDataDiskProperties),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{Cancel: cancel})
|
|
}
|
|
|
|
// DetachDataDiskSender sends the DetachDataDisk request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client VirtualMachinesClient) DetachDataDiskSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoPollForAsynchronous(client.PollingDelay))
|
|
}
|
|
|
|
// DetachDataDiskResponder handles the response to the DetachDataDisk request. The method always
|
|
// closes the http.Response Body.
|
|
func (client VirtualMachinesClient) DetachDataDiskResponder(resp *http.Response) (result autorest.Response, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
|
autorest.ByClosing())
|
|
result.Response = resp
|
|
return
|
|
}
|
|
|
|
// Get get virtual machine.
|
|
//
|
|
// resourceGroupName is the name of the resource group. labName is the name of
|
|
// the lab. name is the name of the virtual machine. expand is specify the
|
|
// $expand query. Example:
|
|
// 'properties($expand=artifacts,computeVm,networkInterface,applicableSchedule)'
|
|
func (client VirtualMachinesClient) Get(resourceGroupName string, labName string, name string, expand string) (result LabVirtualMachine, err error) {
|
|
req, err := client.GetPreparer(resourceGroupName, labName, name, expand)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Get", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.GetSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Get", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.GetResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Get", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetPreparer prepares the Get request.
|
|
func (client VirtualMachinesClient) GetPreparer(resourceGroupName string, labName string, name string, expand string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"labName": autorest.Encode("path", labName),
|
|
"name": autorest.Encode("path", name),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2016-05-15"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
if len(expand) > 0 {
|
|
queryParameters["$expand"] = autorest.Encode("query", expand)
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsGet(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// GetSender sends the Get request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client VirtualMachinesClient) GetSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// GetResponder handles the response to the Get request. The method always
|
|
// closes the http.Response Body.
|
|
func (client VirtualMachinesClient) GetResponder(resp *http.Response) (result LabVirtualMachine, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// List list virtual machines in a given lab.
|
|
//
|
|
// resourceGroupName is the name of the resource group. labName is the name of
|
|
// the lab. expand is specify the $expand query. Example:
|
|
// 'properties($expand=artifacts,computeVm,networkInterface,applicableSchedule)'
|
|
// filter is the filter to apply to the operation. top is the maximum number of
|
|
// resources to return from the operation. orderby is the ordering expression
|
|
// for the results, using OData notation.
|
|
func (client VirtualMachinesClient) List(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (result ResponseWithContinuationLabVirtualMachine, err error) {
|
|
req, err := client.ListPreparer(resourceGroupName, labName, expand, filter, top, orderby)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "List", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "List", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "List", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListPreparer prepares the List request.
|
|
func (client VirtualMachinesClient) ListPreparer(resourceGroupName string, labName string, expand string, filter string, top *int32, orderby string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"labName": autorest.Encode("path", labName),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2016-05-15"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
if len(expand) > 0 {
|
|
queryParameters["$expand"] = autorest.Encode("query", expand)
|
|
}
|
|
if len(filter) > 0 {
|
|
queryParameters["$filter"] = autorest.Encode("query", filter)
|
|
}
|
|
if top != nil {
|
|
queryParameters["$top"] = autorest.Encode("query", *top)
|
|
}
|
|
if len(orderby) > 0 {
|
|
queryParameters["$orderby"] = autorest.Encode("query", orderby)
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsGet(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// ListSender sends the List request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client VirtualMachinesClient) ListSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// ListResponder handles the response to the List request. The method always
|
|
// closes the http.Response Body.
|
|
func (client VirtualMachinesClient) ListResponder(resp *http.Response) (result ResponseWithContinuationLabVirtualMachine, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// ListNextResults retrieves the next set of results, if any.
|
|
func (client VirtualMachinesClient) ListNextResults(lastResults ResponseWithContinuationLabVirtualMachine) (result ResponseWithContinuationLabVirtualMachine, err error) {
|
|
req, err := lastResults.ResponseWithContinuationLabVirtualMachinePreparer()
|
|
if err != nil {
|
|
return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "List", nil, "Failure preparing next results request")
|
|
}
|
|
if req == nil {
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
return result, autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "List", resp, "Failure sending next results request")
|
|
}
|
|
|
|
result, err = client.ListResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "List", resp, "Failure responding to next results request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListApplicableSchedules lists all applicable schedules
|
|
//
|
|
// resourceGroupName is the name of the resource group. labName is the name of
|
|
// the lab. name is the name of the virtual machine.
|
|
func (client VirtualMachinesClient) ListApplicableSchedules(resourceGroupName string, labName string, name string) (result ApplicableSchedule, err error) {
|
|
req, err := client.ListApplicableSchedulesPreparer(resourceGroupName, labName, name)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "ListApplicableSchedules", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListApplicableSchedulesSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "ListApplicableSchedules", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListApplicableSchedulesResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "ListApplicableSchedules", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListApplicableSchedulesPreparer prepares the ListApplicableSchedules request.
|
|
func (client VirtualMachinesClient) ListApplicableSchedulesPreparer(resourceGroupName string, labName string, name string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"labName": autorest.Encode("path", labName),
|
|
"name": autorest.Encode("path", name),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2016-05-15"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsPost(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/listApplicableSchedules", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// ListApplicableSchedulesSender sends the ListApplicableSchedules request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client VirtualMachinesClient) ListApplicableSchedulesSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// ListApplicableSchedulesResponder handles the response to the ListApplicableSchedules request. The method always
|
|
// closes the http.Response Body.
|
|
func (client VirtualMachinesClient) ListApplicableSchedulesResponder(resp *http.Response) (result ApplicableSchedule, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// Start start a virtual machine. This operation can take a while to complete.
|
|
// This method may poll for completion. Polling can be canceled by passing the
|
|
// cancel channel argument. The channel will be used to cancel polling and any
|
|
// outstanding HTTP requests.
|
|
//
|
|
// resourceGroupName is the name of the resource group. labName is the name of
|
|
// the lab. name is the name of the virtual machine.
|
|
func (client VirtualMachinesClient) Start(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
|
|
resultChan := make(chan autorest.Response, 1)
|
|
errChan := make(chan error, 1)
|
|
go func() {
|
|
var err error
|
|
var result autorest.Response
|
|
defer func() {
|
|
resultChan <- result
|
|
errChan <- err
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
req, err := client.StartPreparer(resourceGroupName, labName, name, cancel)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Start", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.StartSender(req)
|
|
if err != nil {
|
|
result.Response = resp
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Start", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.StartResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Start", resp, "Failure responding to request")
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// StartPreparer prepares the Start request.
|
|
func (client VirtualMachinesClient) StartPreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"labName": autorest.Encode("path", labName),
|
|
"name": autorest.Encode("path", name),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2016-05-15"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsPost(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/start", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{Cancel: cancel})
|
|
}
|
|
|
|
// StartSender sends the Start request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client VirtualMachinesClient) StartSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoPollForAsynchronous(client.PollingDelay))
|
|
}
|
|
|
|
// StartResponder handles the response to the Start request. The method always
|
|
// closes the http.Response Body.
|
|
func (client VirtualMachinesClient) StartResponder(resp *http.Response) (result autorest.Response, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
|
autorest.ByClosing())
|
|
result.Response = resp
|
|
return
|
|
}
|
|
|
|
// Stop stop a virtual machine This operation can take a while to complete.
|
|
// This method may poll for completion. Polling can be canceled by passing the
|
|
// cancel channel argument. The channel will be used to cancel polling and any
|
|
// outstanding HTTP requests.
|
|
//
|
|
// resourceGroupName is the name of the resource group. labName is the name of
|
|
// the lab. name is the name of the virtual machine.
|
|
func (client VirtualMachinesClient) Stop(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
|
|
resultChan := make(chan autorest.Response, 1)
|
|
errChan := make(chan error, 1)
|
|
go func() {
|
|
var err error
|
|
var result autorest.Response
|
|
defer func() {
|
|
resultChan <- result
|
|
errChan <- err
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
req, err := client.StopPreparer(resourceGroupName, labName, name, cancel)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Stop", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.StopSender(req)
|
|
if err != nil {
|
|
result.Response = resp
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Stop", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.StopResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Stop", resp, "Failure responding to request")
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// StopPreparer prepares the Stop request.
|
|
func (client VirtualMachinesClient) StopPreparer(resourceGroupName string, labName string, name string, cancel <-chan struct{}) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"labName": autorest.Encode("path", labName),
|
|
"name": autorest.Encode("path", name),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2016-05-15"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsPost(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/stop", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{Cancel: cancel})
|
|
}
|
|
|
|
// StopSender sends the Stop request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client VirtualMachinesClient) StopSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoPollForAsynchronous(client.PollingDelay))
|
|
}
|
|
|
|
// StopResponder handles the response to the Stop request. The method always
|
|
// closes the http.Response Body.
|
|
func (client VirtualMachinesClient) StopResponder(resp *http.Response) (result autorest.Response, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
|
autorest.ByClosing())
|
|
result.Response = resp
|
|
return
|
|
}
|
|
|
|
// Update modify properties of virtual machines.
|
|
//
|
|
// resourceGroupName is the name of the resource group. labName is the name of
|
|
// the lab. name is the name of the virtual machine. labVirtualMachine is a
|
|
// virtual machine.
|
|
func (client VirtualMachinesClient) Update(resourceGroupName string, labName string, name string, labVirtualMachine LabVirtualMachineFragment) (result LabVirtualMachine, err error) {
|
|
req, err := client.UpdatePreparer(resourceGroupName, labName, name, labVirtualMachine)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Update", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.UpdateSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Update", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.UpdateResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "devtestlabs.VirtualMachinesClient", "Update", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// UpdatePreparer prepares the Update request.
|
|
func (client VirtualMachinesClient) UpdatePreparer(resourceGroupName string, labName string, name string, labVirtualMachine LabVirtualMachineFragment) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"labName": autorest.Encode("path", labName),
|
|
"name": autorest.Encode("path", name),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
}
|
|
|
|
const APIVersion = "2016-05-15"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsJSON(),
|
|
autorest.AsPatch(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}", pathParameters),
|
|
autorest.WithJSON(labVirtualMachine),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// UpdateSender sends the Update request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client VirtualMachinesClient) UpdateSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// UpdateResponder handles the response to the Update request. The method always
|
|
// closes the http.Response Body.
|
|
func (client VirtualMachinesClient) UpdateResponder(resp *http.Response) (result LabVirtualMachine, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|