diff --git a/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/client.go b/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/client.go new file mode 100644 index 000000000000..cb9cc5d72e9e --- /dev/null +++ b/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/client.go @@ -0,0 +1,52 @@ +// Package hybridcompute implements the Azure ARM Hybridcompute service API version 2019-12-12. +// +// The Hybrid Compute Management Client. +package hybridcompute + +// 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. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Hybridcompute + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Hybridcompute. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/hybridcomputeapi/interfaces.go b/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/hybridcomputeapi/interfaces.go new file mode 100644 index 000000000000..b7a2fae5d0f6 --- /dev/null +++ b/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/hybridcomputeapi/interfaces.go @@ -0,0 +1,58 @@ +package hybridcomputeapi + +// 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. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute" + "github.com/Azure/go-autorest/autorest" +) + +// MachinesClientAPI contains the set of methods on the MachinesClient type. +type MachinesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, name string, parameters hybridcompute.Machine) (result hybridcompute.Machine, err error) + Delete(ctx context.Context, resourceGroupName string, name string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, name string, expand hybridcompute.InstanceViewTypes) (result hybridcompute.Machine, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result hybridcompute.MachineListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result hybridcompute.MachineListResultIterator, err error) + ListBySubscription(ctx context.Context) (result hybridcompute.MachineListResultPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result hybridcompute.MachineListResultIterator, err error) + Reconnect(ctx context.Context, resourceGroupName string, name string, parameters hybridcompute.MachineReconnect) (result hybridcompute.Machine, err error) + Update(ctx context.Context, resourceGroupName string, name string, parameters hybridcompute.MachineUpdate) (result hybridcompute.Machine, err error) +} + +var _ MachinesClientAPI = (*hybridcompute.MachinesClient)(nil) + +// MachineExtensionsClientAPI contains the set of methods on the MachineExtensionsClient type. +type MachineExtensionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters hybridcompute.MachineExtension) (result hybridcompute.MachineExtensionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, name string, extensionName string) (result hybridcompute.MachineExtensionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, name string, extensionName string) (result hybridcompute.MachineExtension, err error) + List(ctx context.Context, resourceGroupName string, name string, expand string) (result hybridcompute.MachineExtensionsListResultPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, name string, expand string) (result hybridcompute.MachineExtensionsListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters hybridcompute.MachineExtensionUpdate) (result hybridcompute.MachineExtensionsUpdateFuture, err error) +} + +var _ MachineExtensionsClientAPI = (*hybridcompute.MachineExtensionsClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result hybridcompute.OperationListResult, err error) +} + +var _ OperationsClientAPI = (*hybridcompute.OperationsClient)(nil) diff --git a/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/machineextensions.go b/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/machineextensions.go new file mode 100644 index 000000000000..a357a244a518 --- /dev/null +++ b/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/machineextensions.go @@ -0,0 +1,514 @@ +package hybridcompute + +// 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. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MachineExtensionsClient is the the Hybrid Compute Management Client. +type MachineExtensionsClient struct { + BaseClient +} + +// NewMachineExtensionsClient creates an instance of the MachineExtensionsClient client. +func NewMachineExtensionsClient(subscriptionID string) MachineExtensionsClient { + return NewMachineExtensionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMachineExtensionsClientWithBaseURI creates an instance of the MachineExtensionsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewMachineExtensionsClientWithBaseURI(baseURI string, subscriptionID string) MachineExtensionsClient { + return MachineExtensionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate the operation to create or update the extension. +// Parameters: +// resourceGroupName - the name of the resource group. +// name - the name of the machine where the extension should be created or updated. +// extensionName - the name of the machine extension. +// extensionParameters - parameters supplied to the Create Machine Extension operation. +func (client MachineExtensionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters MachineExtension) (result MachineExtensionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachineExtensionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridcompute.MachineExtensionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, name, extensionName, extensionParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client MachineExtensionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters MachineExtension) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "extensionName": autorest.Encode("path", extensionName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-12" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/extensions/{extensionName}", pathParameters), + autorest.WithJSON(extensionParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client MachineExtensionsClient) CreateOrUpdateSender(req *http.Request) (future MachineExtensionsCreateOrUpdateFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client MachineExtensionsClient) CreateOrUpdateResponder(resp *http.Response) (result MachineExtension, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the operation to delete the extension. +// Parameters: +// resourceGroupName - the name of the resource group. +// name - the name of the machine where the extension should be deleted. +// extensionName - the name of the machine extension. +func (client MachineExtensionsClient) Delete(ctx context.Context, resourceGroupName string, name string, extensionName string) (result MachineExtensionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachineExtensionsClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridcompute.MachineExtensionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, name, extensionName) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client MachineExtensionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, name string, extensionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "extensionName": autorest.Encode("path", extensionName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-12" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/extensions/{extensionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client MachineExtensionsClient) DeleteSender(req *http.Request) (future MachineExtensionsDeleteFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client MachineExtensionsClient) 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 +} + +// Get the operation to get the extension. +// Parameters: +// resourceGroupName - the name of the resource group. +// name - the name of the machine containing the extension. +// extensionName - the name of the machine extension. +func (client MachineExtensionsClient) Get(ctx context.Context, resourceGroupName string, name string, extensionName string) (result MachineExtension, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachineExtensionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridcompute.MachineExtensionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, name, extensionName) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client MachineExtensionsClient) GetPreparer(ctx context.Context, resourceGroupName string, name string, extensionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "extensionName": autorest.Encode("path", extensionName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-12" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/extensions/{extensionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client MachineExtensionsClient) GetSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client MachineExtensionsClient) GetResponder(resp *http.Response) (result MachineExtension, 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 the operation to get all extensions of a non-Azure machine +// Parameters: +// resourceGroupName - the name of the resource group. +// name - the name of the machine containing the extension. +// expand - the expand expression to apply on the operation. +func (client MachineExtensionsClient) List(ctx context.Context, resourceGroupName string, name string, expand string) (result MachineExtensionsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachineExtensionsClient.List") + defer func() { + sc := -1 + if result.melr.Response.Response != nil { + sc = result.melr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridcompute.MachineExtensionsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, name, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.melr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsClient", "List", resp, "Failure sending request") + return + } + + result.melr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client MachineExtensionsClient) ListPreparer(ctx context.Context, resourceGroupName string, name string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-12" + 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.HybridCompute/machines/{name}/extensions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client MachineExtensionsClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client MachineExtensionsClient) ListResponder(resp *http.Response) (result MachineExtensionsListResult, 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 MachineExtensionsClient) listNextResults(ctx context.Context, lastResults MachineExtensionsListResult) (result MachineExtensionsListResult, err error) { + req, err := lastResults.machineExtensionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsClient", "listNextResults", 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, "hybridcompute.MachineExtensionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client MachineExtensionsClient) ListComplete(ctx context.Context, resourceGroupName string, name string, expand string) (result MachineExtensionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachineExtensionsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, name, expand) + return +} + +// Update the operation to create or update the extension. +// Parameters: +// resourceGroupName - the name of the resource group. +// name - the name of the machine where the extension should be created or updated. +// extensionName - the name of the machine extension. +// extensionParameters - parameters supplied to the Create Machine Extension operation. +func (client MachineExtensionsClient) Update(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters MachineExtensionUpdate) (result MachineExtensionsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachineExtensionsClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridcompute.MachineExtensionsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, name, extensionName, extensionParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client MachineExtensionsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters MachineExtensionUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "extensionName": autorest.Encode("path", extensionName), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-12" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/extensions/{extensionName}", pathParameters), + autorest.WithJSON(extensionParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client MachineExtensionsClient) UpdateSender(req *http.Request) (future MachineExtensionsUpdateFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client MachineExtensionsClient) UpdateResponder(resp *http.Response) (result MachineExtension, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/machines.go b/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/machines.go new file mode 100644 index 000000000000..632c462ac827 --- /dev/null +++ b/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/machines.go @@ -0,0 +1,707 @@ +package hybridcompute + +// 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. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MachinesClient is the the Hybrid Compute Management Client. +type MachinesClient struct { + BaseClient +} + +// NewMachinesClient creates an instance of the MachinesClient client. +func NewMachinesClient(subscriptionID string) MachinesClient { + return NewMachinesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMachinesClientWithBaseURI creates an instance of the MachinesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewMachinesClientWithBaseURI(baseURI string, subscriptionID string) MachinesClient { + return MachinesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate the operation to create or update a hybrid machine resource identity in Azure. +// Parameters: +// resourceGroupName - the name of the resource group. +// name - the name of the hybrid machine. +// parameters - parameters supplied to the Create hybrid machine operation. +func (client MachinesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, name string, parameters Machine) (result Machine, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridcompute.MachinesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, name, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client MachinesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, name string, parameters Machine) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-12" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client MachinesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client MachinesClient) CreateOrUpdateResponder(resp *http.Response) (result Machine, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the operation to remove a hybrid machine identity in Azure. +// Parameters: +// resourceGroupName - the name of the resource group. +// name - the name of the hybrid machine. +func (client MachinesClient) Delete(ctx context.Context, resourceGroupName string, name string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridcompute.MachinesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, name) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client MachinesClient) DeletePreparer(ctx context.Context, resourceGroupName string, name string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-12" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client MachinesClient) DeleteSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client MachinesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieves information about the model view or the instance view of a hybrid machine. +// Parameters: +// resourceGroupName - the name of the resource group. +// name - the name of the hybrid machine. +// expand - the expand expression to apply on the operation. +func (client MachinesClient) Get(ctx context.Context, resourceGroupName string, name string, expand InstanceViewTypes) (result Machine, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridcompute.MachinesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, name, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client MachinesClient) GetPreparer(ctx context.Context, resourceGroupName string, name string, expand InstanceViewTypes) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-12" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(string(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.HybridCompute/machines/{name}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client MachinesClient) GetSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client MachinesClient) GetResponder(resp *http.Response) (result Machine, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup lists all the hybrid machines in the specified resource group. Use the nextLink property in the +// response to get the next page of hybrid machines. +// Parameters: +// resourceGroupName - the name of the resource group. +func (client MachinesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result MachineListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.mlr.Response.Response != nil { + sc = result.mlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridcompute.MachinesClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.mlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.mlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client MachinesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-12" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client MachinesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client MachinesClient) ListByResourceGroupResponder(resp *http.Response) (result MachineListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client MachinesClient) listByResourceGroupNextResults(ctx context.Context, lastResults MachineListResult) (result MachineListResult, err error) { + req, err := lastResults.machineListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client MachinesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result MachineListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription lists all the hybrid machines in the specified subscription. Use the nextLink property in the +// response to get the next page of hybrid machines. +func (client MachinesClient) ListBySubscription(ctx context.Context) (result MachineListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListBySubscription") + defer func() { + sc := -1 + if result.mlr.Response.Response != nil { + sc = result.mlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridcompute.MachinesClient", "ListBySubscription", err.Error()) + } + + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.mlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.mlr, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client MachinesClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-12" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.HybridCompute/machines", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client MachinesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client MachinesClient) ListBySubscriptionResponder(resp *http.Response) (result MachineListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client MachinesClient) listBySubscriptionNextResults(ctx context.Context, lastResults MachineListResult) (result MachineListResult, err error) { + req, err := lastResults.machineListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client MachinesClient) ListBySubscriptionComplete(ctx context.Context) (result MachineListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} + +// Reconnect the operation to reconnect a hybrid machine resource to its identity in Azure. +// Parameters: +// resourceGroupName - the name of the resource group. +// name - the name of the hybrid machine. +// parameters - parameters supplied to the Reconnect hybrid machine operation. +func (client MachinesClient) Reconnect(ctx context.Context, resourceGroupName string, name string, parameters MachineReconnect) (result Machine, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.Reconnect") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridcompute.MachinesClient", "Reconnect", err.Error()) + } + + req, err := client.ReconnectPreparer(ctx, resourceGroupName, name, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "Reconnect", nil, "Failure preparing request") + return + } + + resp, err := client.ReconnectSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "Reconnect", resp, "Failure sending request") + return + } + + result, err = client.ReconnectResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "Reconnect", resp, "Failure responding to request") + } + + return +} + +// ReconnectPreparer prepares the Reconnect request. +func (client MachinesClient) ReconnectPreparer(ctx context.Context, resourceGroupName string, name string, parameters MachineReconnect) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-12" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}/reconnect", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ReconnectSender sends the Reconnect request. The method will close the +// http.Response Body if it receives an error. +func (client MachinesClient) ReconnectSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ReconnectResponder handles the response to the Reconnect request. The method always +// closes the http.Response Body. +func (client MachinesClient) ReconnectResponder(resp *http.Response) (result Machine, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update the operation to update a hybrid machine. +// Parameters: +// resourceGroupName - the name of the resource group. +// name - the name of the hybrid machine. +// parameters - parameters supplied to the Update hybrid machine operation. +func (client MachinesClient) Update(ctx context.Context, resourceGroupName string, name string, parameters MachineUpdate) (result Machine, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: client.SubscriptionID, + Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("hybridcompute.MachinesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, name, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachinesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client MachinesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, name string, parameters MachineUpdate) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-12" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{name}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client MachinesClient) UpdateSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client MachinesClient) UpdateResponder(resp *http.Response) (result Machine, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/models.go b/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/models.go new file mode 100644 index 000000000000..eef7874878be --- /dev/null +++ b/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/models.go @@ -0,0 +1,1436 @@ +package hybridcompute + +// 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. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute" + +// InstanceViewTypes enumerates the values for instance view types. +type InstanceViewTypes string + +const ( + // InstanceView ... + InstanceView InstanceViewTypes = "instanceView" +) + +// PossibleInstanceViewTypesValues returns an array of possible values for the InstanceViewTypes const type. +func PossibleInstanceViewTypesValues() []InstanceViewTypes { + return []InstanceViewTypes{InstanceView} +} + +// ResourceIdentityType enumerates the values for resource identity type. +type ResourceIdentityType string + +const ( + // SystemAssigned ... + SystemAssigned ResourceIdentityType = "SystemAssigned" +) + +// PossibleResourceIdentityTypeValues returns an array of possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{SystemAssigned} +} + +// SkuTier enumerates the values for sku tier. +type SkuTier string + +const ( + // Basic ... + Basic SkuTier = "Basic" + // Free ... + Free SkuTier = "Free" + // Premium ... + Premium SkuTier = "Premium" + // Standard ... + Standard SkuTier = "Standard" +) + +// PossibleSkuTierValues returns an array of possible values for the SkuTier const type. +func PossibleSkuTierValues() []SkuTier { + return []SkuTier{Basic, Free, Premium, Standard} +} + +// StatusLevelTypes enumerates the values for status level types. +type StatusLevelTypes string + +const ( + // Error ... + Error StatusLevelTypes = "Error" + // Info ... + Info StatusLevelTypes = "Info" + // Warning ... + Warning StatusLevelTypes = "Warning" +) + +// PossibleStatusLevelTypesValues returns an array of possible values for the StatusLevelTypes const type. +func PossibleStatusLevelTypesValues() []StatusLevelTypes { + return []StatusLevelTypes{Error, Info, Warning} +} + +// StatusTypes enumerates the values for status types. +type StatusTypes string + +const ( + // StatusTypesConnected ... + StatusTypesConnected StatusTypes = "Connected" + // StatusTypesDisconnected ... + StatusTypesDisconnected StatusTypes = "Disconnected" + // StatusTypesError ... + StatusTypesError StatusTypes = "Error" +) + +// PossibleStatusTypesValues returns an array of possible values for the StatusTypes const type. +func PossibleStatusTypesValues() []StatusTypes { + return []StatusTypes{StatusTypesConnected, StatusTypesDisconnected, StatusTypesError} +} + +// AzureEntityResource the resource model definition for a Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// ErrorAdditionalInfo the resource management error additional info. +type ErrorAdditionalInfo struct { + // Type - READ-ONLY; The additional info type. + Type *string `json:"type,omitempty"` + // Info - READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty"` +} + +// ErrorDetail ... +type ErrorDetail struct { + // Code - The error's code. + Code *string `json:"code,omitempty"` + // Message - A human readable error message. + Message *string `json:"message,omitempty"` + // Target - Indicates which property in the request is responsible for the error. + Target *string `json:"target,omitempty"` + // Details - Additional error details. + Details *[]ErrorDetail `json:"details,omitempty"` +} + +// ErrorResponse the resource management error response. +type ErrorResponse struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The error target. + Target *string `json:"target,omitempty"` + // Details - READ-ONLY; The error details. + Details *[]ErrorResponse `json:"details,omitempty"` + // AdditionalInfo - READ-ONLY; The error additional info. + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` +} + +// Identity identity for the resource. +type Identity struct { + // PrincipalID - READ-ONLY; The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty"` + // Type - The identity type. Possible values include: 'SystemAssigned' + Type ResourceIdentityType `json:"type,omitempty"` +} + +// LocationData metadata pertaining to the geographic location of the resource. +type LocationData struct { + // Name - A canonical name for the geographic or physical location. + Name *string `json:"name,omitempty"` + // City - The city or locality where the resource is located. + City *string `json:"city,omitempty"` + // District - The district, state, or province where the resource is located. + District *string `json:"district,omitempty"` + // CountryOrRegion - The country or region where the resource is located + CountryOrRegion *string `json:"countryOrRegion,omitempty"` +} + +// Machine describes a hybrid machine. +type Machine struct { + autorest.Response `json:"-"` + // MachinePropertiesModel - Hybrid Compute Machine properties + *MachinePropertiesModel `json:"properties,omitempty"` + Identity *MachineIdentity `json:"identity,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Machine. +func (mVar Machine) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mVar.MachinePropertiesModel != nil { + objectMap["properties"] = mVar.MachinePropertiesModel + } + if mVar.Identity != nil { + objectMap["identity"] = mVar.Identity + } + if mVar.Tags != nil { + objectMap["tags"] = mVar.Tags + } + if mVar.Location != nil { + objectMap["location"] = mVar.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Machine struct. +func (mVar *Machine) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var machinePropertiesModel MachinePropertiesModel + err = json.Unmarshal(*v, &machinePropertiesModel) + if err != nil { + return err + } + mVar.MachinePropertiesModel = &machinePropertiesModel + } + case "identity": + if v != nil { + var identity MachineIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + mVar.Identity = &identity + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mVar.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + mVar.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mVar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mVar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mVar.Type = &typeVar + } + } + } + + return nil +} + +// MachineExtension describes a Machine Extension. +type MachineExtension struct { + autorest.Response `json:"-"` + // MachineExtensionProperties - Describes Machine Extension Properties. + *MachineExtensionProperties `json:"properties,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for MachineExtension. +func (me MachineExtension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if me.MachineExtensionProperties != nil { + objectMap["properties"] = me.MachineExtensionProperties + } + if me.Tags != nil { + objectMap["tags"] = me.Tags + } + if me.Location != nil { + objectMap["location"] = me.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MachineExtension struct. +func (me *MachineExtension) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var machineExtensionProperties MachineExtensionProperties + err = json.Unmarshal(*v, &machineExtensionProperties) + if err != nil { + return err + } + me.MachineExtensionProperties = &machineExtensionProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + me.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + me.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + me.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + me.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + me.Type = &typeVar + } + } + } + + return nil +} + +// MachineExtensionInstanceView describes the Machine Extension Instance View. +type MachineExtensionInstanceView struct { + // Name - The machine extension name. + Name *string `json:"name,omitempty"` + // Type - Specifies the type of the extension; an example is "CustomScriptExtension". + Type *string `json:"type,omitempty"` + // TypeHandlerVersion - Specifies the version of the script handler. + TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"` + // Status - Instance view status. + Status *MachineExtensionInstanceViewStatus `json:"status,omitempty"` +} + +// MachineExtensionInstanceViewStatus instance view status. +type MachineExtensionInstanceViewStatus struct { + // Code - The status code. + Code *string `json:"code,omitempty"` + // Level - The level code. Possible values include: 'Info', 'Warning', 'Error' + Level StatusLevelTypes `json:"level,omitempty"` + // DisplayStatus - The short localizable label for the status. + DisplayStatus *string `json:"displayStatus,omitempty"` + // Message - The detailed status message, including for alerts and error messages. + Message *string `json:"message,omitempty"` + // Time - The time of the status. + Time *date.Time `json:"time,omitempty"` +} + +// MachineExtensionProperties describes Machine Extension Properties. +type MachineExtensionProperties struct { + // ForceUpdateTag - How the extension handler should be forced to update even if the extension configuration has not changed. + ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` + // Publisher - The name of the extension handler publisher. + Publisher *string `json:"publisher,omitempty"` + // Type - Specifies the type of the extension; an example is "CustomScriptExtension". + Type *string `json:"type,omitempty"` + // TypeHandlerVersion - Specifies the version of the script handler. + TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"` + // AutoUpgradeMinorVersion - Indicates whether the extension should use a newer minor version if one is available at deployment time. Once deployed, however, the extension will not upgrade minor versions unless redeployed, even with this property set to true. + AutoUpgradeMinorVersion *bool `json:"autoUpgradeMinorVersion,omitempty"` + // Settings - Json formatted public settings for the extension. + Settings interface{} `json:"settings,omitempty"` + // ProtectedSettings - The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. + ProtectedSettings interface{} `json:"protectedSettings,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state, which only appears in the response. + ProvisioningState *string `json:"provisioningState,omitempty"` + // InstanceView - The machine extension instance view. + InstanceView *MachineExtensionPropertiesInstanceView `json:"instanceView,omitempty"` +} + +// MachineExtensionPropertiesInstanceView the machine extension instance view. +type MachineExtensionPropertiesInstanceView struct { + // Name - The machine extension name. + Name *string `json:"name,omitempty"` + // Type - Specifies the type of the extension; an example is "CustomScriptExtension". + Type *string `json:"type,omitempty"` + // TypeHandlerVersion - Specifies the version of the script handler. + TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"` + // Status - Instance view status. + Status *MachineExtensionInstanceViewStatus `json:"status,omitempty"` +} + +// MachineExtensionPropertiesModel describes the properties of a Machine Extension. +type MachineExtensionPropertiesModel struct { + // ForceUpdateTag - How the extension handler should be forced to update even if the extension configuration has not changed. + ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` + // Publisher - The name of the extension handler publisher. + Publisher *string `json:"publisher,omitempty"` + // Type - Specifies the type of the extension; an example is "CustomScriptExtension". + Type *string `json:"type,omitempty"` + // TypeHandlerVersion - Specifies the version of the script handler. + TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"` + // AutoUpgradeMinorVersion - Indicates whether the extension should use a newer minor version if one is available at deployment time. Once deployed, however, the extension will not upgrade minor versions unless redeployed, even with this property set to true. + AutoUpgradeMinorVersion *bool `json:"autoUpgradeMinorVersion,omitempty"` + // Settings - Json formatted public settings for the extension. + Settings interface{} `json:"settings,omitempty"` + // ProtectedSettings - The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. + ProtectedSettings interface{} `json:"protectedSettings,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state, which only appears in the response. + ProvisioningState *string `json:"provisioningState,omitempty"` + // InstanceView - The machine extension instance view. + InstanceView *MachineExtensionPropertiesInstanceView `json:"instanceView,omitempty"` +} + +// MachineExtensionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type MachineExtensionsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *MachineExtensionsCreateOrUpdateFuture) Result(client MachineExtensionsClient) (me MachineExtension, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("hybridcompute.MachineExtensionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if me.Response.Response, err = future.GetResult(sender); err == nil && me.Response.Response.StatusCode != http.StatusNoContent { + me, err = client.CreateOrUpdateResponder(me.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsCreateOrUpdateFuture", "Result", me.Response.Response, "Failure responding to request") + } + } + return +} + +// MachineExtensionsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type MachineExtensionsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *MachineExtensionsDeleteFuture) Result(client MachineExtensionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("hybridcompute.MachineExtensionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// MachineExtensionsListResult describes the Machine Extensions List Result. +type MachineExtensionsListResult struct { + autorest.Response `json:"-"` + // Value - The list of extensions + Value *[]MachineExtension `json:"value,omitempty"` + // NextLink - The uri to fetch the next page of machine extensions. Call ListNext() with this to fetch the next page of extensions. + NextLink *string `json:"nextLink,omitempty"` +} + +// MachineExtensionsListResultIterator provides access to a complete listing of MachineExtension values. +type MachineExtensionsListResultIterator struct { + i int + page MachineExtensionsListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *MachineExtensionsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachineExtensionsListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *MachineExtensionsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter MachineExtensionsListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter MachineExtensionsListResultIterator) Response() MachineExtensionsListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter MachineExtensionsListResultIterator) Value() MachineExtension { + if !iter.page.NotDone() { + return MachineExtension{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the MachineExtensionsListResultIterator type. +func NewMachineExtensionsListResultIterator(page MachineExtensionsListResultPage) MachineExtensionsListResultIterator { + return MachineExtensionsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (melr MachineExtensionsListResult) IsEmpty() bool { + return melr.Value == nil || len(*melr.Value) == 0 +} + +// machineExtensionsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (melr MachineExtensionsListResult) machineExtensionsListResultPreparer(ctx context.Context) (*http.Request, error) { + if melr.NextLink == nil || len(to.String(melr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(melr.NextLink))) +} + +// MachineExtensionsListResultPage contains a page of MachineExtension values. +type MachineExtensionsListResultPage struct { + fn func(context.Context, MachineExtensionsListResult) (MachineExtensionsListResult, error) + melr MachineExtensionsListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *MachineExtensionsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachineExtensionsListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.melr) + if err != nil { + return err + } + page.melr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *MachineExtensionsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page MachineExtensionsListResultPage) NotDone() bool { + return !page.melr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page MachineExtensionsListResultPage) Response() MachineExtensionsListResult { + return page.melr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page MachineExtensionsListResultPage) Values() []MachineExtension { + if page.melr.IsEmpty() { + return nil + } + return *page.melr.Value +} + +// Creates a new instance of the MachineExtensionsListResultPage type. +func NewMachineExtensionsListResultPage(getNextPage func(context.Context, MachineExtensionsListResult) (MachineExtensionsListResult, error)) MachineExtensionsListResultPage { + return MachineExtensionsListResultPage{fn: getNextPage} +} + +// MachineExtensionsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type MachineExtensionsUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *MachineExtensionsUpdateFuture) Result(client MachineExtensionsClient) (me MachineExtension, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("hybridcompute.MachineExtensionsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if me.Response.Response, err = future.GetResult(sender); err == nil && me.Response.Response.StatusCode != http.StatusNoContent { + me, err = client.UpdateResponder(me.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.MachineExtensionsUpdateFuture", "Result", me.Response.Response, "Failure responding to request") + } + } + return +} + +// MachineExtensionUpdate describes a Machine Extension Update. +type MachineExtensionUpdate struct { + // MachineExtensionUpdateProperties - Describes Machine Extension Update Properties. + *MachineExtensionUpdateProperties `json:"properties,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for MachineExtensionUpdate. +func (meu MachineExtensionUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if meu.MachineExtensionUpdateProperties != nil { + objectMap["properties"] = meu.MachineExtensionUpdateProperties + } + if meu.Tags != nil { + objectMap["tags"] = meu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MachineExtensionUpdate struct. +func (meu *MachineExtensionUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var machineExtensionUpdateProperties MachineExtensionUpdateProperties + err = json.Unmarshal(*v, &machineExtensionUpdateProperties) + if err != nil { + return err + } + meu.MachineExtensionUpdateProperties = &machineExtensionUpdateProperties + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + meu.Tags = tags + } + } + } + + return nil +} + +// MachineExtensionUpdateProperties describes Machine Extension Update Properties. +type MachineExtensionUpdateProperties struct { + // ForceUpdateTag - How the extension handler should be forced to update even if the extension configuration has not changed. + ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` + // Publisher - The name of the extension handler publisher. + Publisher *string `json:"publisher,omitempty"` + // Type - Specifies the type of the extension; an example is "CustomScriptExtension". + Type *string `json:"type,omitempty"` + // TypeHandlerVersion - Specifies the version of the script handler. + TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"` + // AutoUpgradeMinorVersion - Indicates whether the extension should use a newer minor version if one is available at deployment time. Once deployed, however, the extension will not upgrade minor versions unless redeployed, even with this property set to true. + AutoUpgradeMinorVersion *bool `json:"autoUpgradeMinorVersion,omitempty"` + // Settings - Json formatted public settings for the extension. + Settings interface{} `json:"settings,omitempty"` + // ProtectedSettings - The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. + ProtectedSettings interface{} `json:"protectedSettings,omitempty"` +} + +// MachineExtensionUpdatePropertiesModel describes the properties of a Machine Extension. +type MachineExtensionUpdatePropertiesModel struct { + // ForceUpdateTag - How the extension handler should be forced to update even if the extension configuration has not changed. + ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` + // Publisher - The name of the extension handler publisher. + Publisher *string `json:"publisher,omitempty"` + // Type - Specifies the type of the extension; an example is "CustomScriptExtension". + Type *string `json:"type,omitempty"` + // TypeHandlerVersion - Specifies the version of the script handler. + TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"` + // AutoUpgradeMinorVersion - Indicates whether the extension should use a newer minor version if one is available at deployment time. Once deployed, however, the extension will not upgrade minor versions unless redeployed, even with this property set to true. + AutoUpgradeMinorVersion *bool `json:"autoUpgradeMinorVersion,omitempty"` + // Settings - Json formatted public settings for the extension. + Settings interface{} `json:"settings,omitempty"` + // ProtectedSettings - The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. + ProtectedSettings interface{} `json:"protectedSettings,omitempty"` +} + +// MachineIdentity ... +type MachineIdentity struct { + // PrincipalID - READ-ONLY; The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty"` + // Type - The identity type. Possible values include: 'SystemAssigned' + Type ResourceIdentityType `json:"type,omitempty"` +} + +// MachineListResult the List hybrid machine operation response. +type MachineListResult struct { + autorest.Response `json:"-"` + // Value - The list of hybrid machines. + Value *[]Machine `json:"value,omitempty"` + // NextLink - The URI to fetch the next page of Machines. Call ListNext() with this URI to fetch the next page of hybrid machines. + NextLink *string `json:"nextLink,omitempty"` +} + +// MachineListResultIterator provides access to a complete listing of Machine values. +type MachineListResultIterator struct { + i int + page MachineListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *MachineListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachineListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *MachineListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter MachineListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter MachineListResultIterator) Response() MachineListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter MachineListResultIterator) Value() Machine { + if !iter.page.NotDone() { + return Machine{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the MachineListResultIterator type. +func NewMachineListResultIterator(page MachineListResultPage) MachineListResultIterator { + return MachineListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mlr MachineListResult) IsEmpty() bool { + return mlr.Value == nil || len(*mlr.Value) == 0 +} + +// machineListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mlr MachineListResult) machineListResultPreparer(ctx context.Context) (*http.Request, error) { + if mlr.NextLink == nil || len(to.String(mlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mlr.NextLink))) +} + +// MachineListResultPage contains a page of Machine values. +type MachineListResultPage struct { + fn func(context.Context, MachineListResult) (MachineListResult, error) + mlr MachineListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *MachineListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MachineListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.mlr) + if err != nil { + return err + } + page.mlr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *MachineListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page MachineListResultPage) NotDone() bool { + return !page.mlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page MachineListResultPage) Response() MachineListResult { + return page.mlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page MachineListResultPage) Values() []Machine { + if page.mlr.IsEmpty() { + return nil + } + return *page.mlr.Value +} + +// Creates a new instance of the MachineListResultPage type. +func NewMachineListResultPage(getNextPage func(context.Context, MachineListResult) (MachineListResult, error)) MachineListResultPage { + return MachineListResultPage{fn: getNextPage} +} + +// MachineProperties describes the properties of a hybrid machine. +type MachineProperties struct { + LocationData *LocationData `json:"locationData,omitempty"` + // OsProfile - Specifies the operating system settings for the hybrid machine. + OsProfile *MachinePropertiesOsProfile `json:"osProfile,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state, which only appears in the response. + ProvisioningState *string `json:"provisioningState,omitempty"` + // Status - READ-ONLY; The status of the hybrid machine agent. Possible values include: 'StatusTypesConnected', 'StatusTypesDisconnected', 'StatusTypesError' + Status StatusTypes `json:"status,omitempty"` + // LastStatusChange - READ-ONLY; The time of the last status change. + LastStatusChange *date.Time `json:"lastStatusChange,omitempty"` + // ErrorDetails - READ-ONLY; Details about the error state. + ErrorDetails *[]ErrorDetail `json:"errorDetails,omitempty"` + // AgentVersion - READ-ONLY; The hybrid machine agent full version. + AgentVersion *string `json:"agentVersion,omitempty"` + // VMID - Specifies the hybrid machine unique ID. + VMID *string `json:"vmId,omitempty"` + // DisplayName - READ-ONLY; Specifies the hybrid machine display name. + DisplayName *string `json:"displayName,omitempty"` + // MachineFqdn - READ-ONLY; Specifies the hybrid machine FQDN. + MachineFqdn *string `json:"machineFqdn,omitempty"` + // ClientPublicKey - Public Key that the client provides to be used during initial resource onboarding + ClientPublicKey *string `json:"clientPublicKey,omitempty"` + // OsName - READ-ONLY; The Operating System running on the hybrid machine. + OsName *string `json:"osName,omitempty"` + // OsVersion - READ-ONLY; The version of Operating System running on the hybrid machine. + OsVersion *string `json:"osVersion,omitempty"` + // Extensions - Machine Extensions information + Extensions *[]MachineExtensionInstanceView `json:"extensions,omitempty"` +} + +// MachinePropertiesModel hybrid Compute Machine properties +type MachinePropertiesModel struct { + LocationData *LocationData `json:"locationData,omitempty"` + // OsProfile - Specifies the operating system settings for the hybrid machine. + OsProfile *MachinePropertiesOsProfile `json:"osProfile,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state, which only appears in the response. + ProvisioningState *string `json:"provisioningState,omitempty"` + // Status - READ-ONLY; The status of the hybrid machine agent. Possible values include: 'StatusTypesConnected', 'StatusTypesDisconnected', 'StatusTypesError' + Status StatusTypes `json:"status,omitempty"` + // LastStatusChange - READ-ONLY; The time of the last status change. + LastStatusChange *date.Time `json:"lastStatusChange,omitempty"` + // ErrorDetails - READ-ONLY; Details about the error state. + ErrorDetails *[]ErrorDetail `json:"errorDetails,omitempty"` + // AgentVersion - READ-ONLY; The hybrid machine agent full version. + AgentVersion *string `json:"agentVersion,omitempty"` + // VMID - Specifies the hybrid machine unique ID. + VMID *string `json:"vmId,omitempty"` + // DisplayName - READ-ONLY; Specifies the hybrid machine display name. + DisplayName *string `json:"displayName,omitempty"` + // MachineFqdn - READ-ONLY; Specifies the hybrid machine FQDN. + MachineFqdn *string `json:"machineFqdn,omitempty"` + // ClientPublicKey - Public Key that the client provides to be used during initial resource onboarding + ClientPublicKey *string `json:"clientPublicKey,omitempty"` + // OsName - READ-ONLY; The Operating System running on the hybrid machine. + OsName *string `json:"osName,omitempty"` + // OsVersion - READ-ONLY; The version of Operating System running on the hybrid machine. + OsVersion *string `json:"osVersion,omitempty"` + // Extensions - Machine Extensions information + Extensions *[]MachineExtensionInstanceView `json:"extensions,omitempty"` +} + +// MachinePropertiesOsProfile specifies the operating system settings for the hybrid machine. +type MachinePropertiesOsProfile struct { + // ComputerName - READ-ONLY; Specifies the host OS name of the hybrid machine. + ComputerName *string `json:"computerName,omitempty"` +} + +// MachineReconnect describes a hybrid machine reconnect. +type MachineReconnect struct { + // MachineReconnectPropertiesModel - Hybrid Compute Machine properties + *MachineReconnectPropertiesModel `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for MachineReconnect. +func (mr MachineReconnect) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mr.MachineReconnectPropertiesModel != nil { + objectMap["properties"] = mr.MachineReconnectPropertiesModel + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MachineReconnect struct. +func (mr *MachineReconnect) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var machineReconnectPropertiesModel MachineReconnectPropertiesModel + err = json.Unmarshal(*v, &machineReconnectPropertiesModel) + if err != nil { + return err + } + mr.MachineReconnectPropertiesModel = &machineReconnectPropertiesModel + } + } + } + + return nil +} + +// MachineReconnectProperties describes the properties required to reconnect a hybrid machine. +type MachineReconnectProperties struct { + // VMID - Specifies the hybrid machine unique ID. + VMID *string `json:"vmId,omitempty"` + // ClientPublicKey - Public Key that the client provides to be used during initial resource onboarding. + ClientPublicKey *string `json:"clientPublicKey,omitempty"` +} + +// MachineReconnectPropertiesModel hybrid Compute Machine properties +type MachineReconnectPropertiesModel struct { + // VMID - Specifies the hybrid machine unique ID. + VMID *string `json:"vmId,omitempty"` + // ClientPublicKey - Public Key that the client provides to be used during initial resource onboarding. + ClientPublicKey *string `json:"clientPublicKey,omitempty"` +} + +// MachineUpdate describes a hybrid machine Update. +type MachineUpdate struct { + // MachineUpdateIdentity - Hybrid Compute Machine Managed Identity + *MachineUpdateIdentity `json:"identity,omitempty"` + // MachineUpdatePropertiesModel - Hybrid Compute Machine properties + *MachineUpdatePropertiesModel `json:"properties,omitempty"` + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for MachineUpdate. +func (mu MachineUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mu.MachineUpdateIdentity != nil { + objectMap["identity"] = mu.MachineUpdateIdentity + } + if mu.MachineUpdatePropertiesModel != nil { + objectMap["properties"] = mu.MachineUpdatePropertiesModel + } + if mu.Tags != nil { + objectMap["tags"] = mu.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for MachineUpdate struct. +func (mu *MachineUpdate) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "identity": + if v != nil { + var machineUpdateIdentity MachineUpdateIdentity + err = json.Unmarshal(*v, &machineUpdateIdentity) + if err != nil { + return err + } + mu.MachineUpdateIdentity = &machineUpdateIdentity + } + case "properties": + if v != nil { + var machineUpdatePropertiesModel MachineUpdatePropertiesModel + err = json.Unmarshal(*v, &machineUpdatePropertiesModel) + if err != nil { + return err + } + mu.MachineUpdatePropertiesModel = &machineUpdatePropertiesModel + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + mu.Tags = tags + } + } + } + + return nil +} + +// MachineUpdateIdentity hybrid Compute Machine Managed Identity +type MachineUpdateIdentity struct { + // PrincipalID - READ-ONLY; The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty"` + // Type - The identity type. Possible values include: 'SystemAssigned' + Type ResourceIdentityType `json:"type,omitempty"` +} + +// MachineUpdateProperties describes the ARM updatable properties of a hybrid machine. +type MachineUpdateProperties struct { + LocationData *LocationData `json:"locationData,omitempty"` +} + +// MachineUpdatePropertiesModel hybrid Compute Machine properties +type MachineUpdatePropertiesModel struct { + LocationData *LocationData `json:"locationData,omitempty"` +} + +// OperationListResult the List Compute Operation operation response. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of compute operations + Value *[]OperationValue `json:"value,omitempty"` +} + +// OperationValue describes the properties of a Compute Operation value. +type OperationValue struct { + // Origin - READ-ONLY; The origin of the compute operation. + Origin *string `json:"origin,omitempty"` + // Name - READ-ONLY; The name of the compute operation. + Name *string `json:"name,omitempty"` + // OperationValueDisplay - Display properties + *OperationValueDisplay `json:"display,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationValue. +func (ov OperationValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ov.OperationValueDisplay != nil { + objectMap["display"] = ov.OperationValueDisplay + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OperationValue struct. +func (ov *OperationValue) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "origin": + if v != nil { + var origin string + err = json.Unmarshal(*v, &origin) + if err != nil { + return err + } + ov.Origin = &origin + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ov.Name = &name + } + case "display": + if v != nil { + var operationValueDisplay OperationValueDisplay + err = json.Unmarshal(*v, &operationValueDisplay) + if err != nil { + return err + } + ov.OperationValueDisplay = &operationValueDisplay + } + } + } + + return nil +} + +// OperationValueDisplay display properties +type OperationValueDisplay struct { + // Operation - READ-ONLY; The display name of the compute operation. + Operation *string `json:"operation,omitempty"` + // Resource - READ-ONLY; The display name of the resource the operation applies to. + Resource *string `json:"resource,omitempty"` + // Description - READ-ONLY; The description of the operation. + Description *string `json:"description,omitempty"` + // Provider - READ-ONLY; The resource provider for the operation. + Provider *string `json:"provider,omitempty"` +} + +// OperationValueDisplayModel describes the properties of a Hybrid Compute Operation Value Display. +type OperationValueDisplayModel struct { + // Operation - READ-ONLY; The display name of the compute operation. + Operation *string `json:"operation,omitempty"` + // Resource - READ-ONLY; The display name of the resource the operation applies to. + Resource *string `json:"resource,omitempty"` + // Description - READ-ONLY; The description of the operation. + Description *string `json:"description,omitempty"` + // Provider - READ-ONLY; The resource provider for the operation. + Provider *string `json:"provider,omitempty"` +} + +// OSProfile specifies the operating system settings for the hybrid machine. +type OSProfile struct { + // ComputerName - READ-ONLY; Specifies the host OS name of the hybrid machine. + ComputerName *string `json:"computerName,omitempty"` +} + +// Plan plan for the resource. +type Plan struct { + // Name - A user defined name of the 3rd Party Artifact that is being procured. + Name *string `json:"name,omitempty"` + // Publisher - The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic + Publisher *string `json:"publisher,omitempty"` + // Product - The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact at the time of Data Market onboarding. + Product *string `json:"product,omitempty"` + // PromotionCode - A publisher provided promotion code as provisioned in Data Market for the said product/artifact. + PromotionCode *string `json:"promotionCode,omitempty"` + // Version - The version of the desired product/artifact. + Version *string `json:"version,omitempty"` +} + +// ProxyResource the resource model definition for a ARM proxy resource. It will have everything other than +// required location and tags +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// Resource ... +type Resource struct { + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// ResourceModelWithAllowedPropertySet the resource model definition containing the full set of allowed +// properties for a resource. Except properties bag, there cannot be a top level property outside of this +// set. +type ResourceModelWithAllowedPropertySet struct { + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts.. + Type *string `json:"type,omitempty"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ManagedBy - The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another azure resource. If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource. + ManagedBy *string `json:"managedBy,omitempty"` + // Kind - Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + Kind *string `json:"kind,omitempty"` + // Etag - READ-ONLY; The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + Etag *string `json:"etag,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + Identity *ResourceModelWithAllowedPropertySetIdentity `json:"identity,omitempty"` + Sku *ResourceModelWithAllowedPropertySetSku `json:"sku,omitempty"` + Plan *ResourceModelWithAllowedPropertySetPlan `json:"plan,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceModelWithAllowedPropertySet. +func (rmwaps ResourceModelWithAllowedPropertySet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rmwaps.Location != nil { + objectMap["location"] = rmwaps.Location + } + if rmwaps.ManagedBy != nil { + objectMap["managedBy"] = rmwaps.ManagedBy + } + if rmwaps.Kind != nil { + objectMap["kind"] = rmwaps.Kind + } + if rmwaps.Tags != nil { + objectMap["tags"] = rmwaps.Tags + } + if rmwaps.Identity != nil { + objectMap["identity"] = rmwaps.Identity + } + if rmwaps.Sku != nil { + objectMap["sku"] = rmwaps.Sku + } + if rmwaps.Plan != nil { + objectMap["plan"] = rmwaps.Plan + } + return json.Marshal(objectMap) +} + +// ResourceModelWithAllowedPropertySetIdentity ... +type ResourceModelWithAllowedPropertySetIdentity struct { + // PrincipalID - READ-ONLY; The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty"` + // Type - The identity type. Possible values include: 'SystemAssigned' + Type ResourceIdentityType `json:"type,omitempty"` +} + +// ResourceModelWithAllowedPropertySetPlan ... +type ResourceModelWithAllowedPropertySetPlan struct { + // Name - A user defined name of the 3rd Party Artifact that is being procured. + Name *string `json:"name,omitempty"` + // Publisher - The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic + Publisher *string `json:"publisher,omitempty"` + // Product - The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact at the time of Data Market onboarding. + Product *string `json:"product,omitempty"` + // PromotionCode - A publisher provided promotion code as provisioned in Data Market for the said product/artifact. + PromotionCode *string `json:"promotionCode,omitempty"` + // Version - The version of the desired product/artifact. + Version *string `json:"version,omitempty"` +} + +// ResourceModelWithAllowedPropertySetSku ... +type ResourceModelWithAllowedPropertySetSku struct { + // Name - The name of the SKU. Ex - P3. It is typically a letter+number code + Name *string `json:"name,omitempty"` + // Tier - This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. Possible values include: 'Free', 'Basic', 'Standard', 'Premium' + Tier SkuTier `json:"tier,omitempty"` + // Size - The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. + Size *string `json:"size,omitempty"` + // Family - If the service has different generations of hardware, for the same SKU, then that can be captured here. + Family *string `json:"family,omitempty"` + // Capacity - If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the resource this may be omitted. + Capacity *int32 `json:"capacity,omitempty"` +} + +// Sku the resource model definition representing SKU +type Sku struct { + // Name - The name of the SKU. Ex - P3. It is typically a letter+number code + Name *string `json:"name,omitempty"` + // Tier - This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. Possible values include: 'Free', 'Basic', 'Standard', 'Premium' + Tier SkuTier `json:"tier,omitempty"` + // Size - The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. + Size *string `json:"size,omitempty"` + // Family - If the service has different generations of hardware, for the same SKU, then that can be captured here. + Family *string `json:"family,omitempty"` + // Capacity - If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the resource this may be omitted. + Capacity *int32 `json:"capacity,omitempty"` +} + +// TrackedResource the resource model definition for a ARM tracked top level resource +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} + +// UpdateResource the Update Resource model definition. +type UpdateResource struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for UpdateResource. +func (ur UpdateResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ur.Tags != nil { + objectMap["tags"] = ur.Tags + } + return json.Marshal(objectMap) +} diff --git a/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/operations.go b/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/operations.go new file mode 100644 index 000000000000..812cd467c641 --- /dev/null +++ b/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/operations.go @@ -0,0 +1,110 @@ +package hybridcompute + +// 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. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the the Hybrid Compute Management Client. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List gets a list of hybrid compute operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hybridcompute.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hybridcompute.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2019-12-12" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.HybridCompute/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/version.go b/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/version.go new file mode 100644 index 000000000000..3c86dc00fa66 --- /dev/null +++ b/services/preview/hybridcompute/mgmt/2019-12-12/hybridcompute/version.go @@ -0,0 +1,30 @@ +package hybridcompute + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " hybridcompute/2019-12-12" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}