From 4bb3b52b6d21de732b6fd15ec605b307d15c8ec6 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 8 Aug 2023 09:07:07 +0000 Subject: [PATCH] CodeGen from PR 25147 in Azure/azure-rest-api-specs Merge 4b2b0a7740c29f57efcdd3b016e3b1bd82fc76db into ad997e99eccc15b7ab4cd66ae3f1f9534a1e2628 --- .../armconnectedvmware/CHANGELOG.md | 84 ++ .../armconnectedvmware/autorest.md | 6 +- ...urearcvmwaremanagementserviceapi_client.go | 127 +++ .../armconnectedvmware/client_factory.go | 66 +- .../armconnectedvmware/clusters_client.go | 88 +- .../clusters_client_example_test.go | 262 ------ .../armconnectedvmware/constants.go | 4 +- .../armconnectedvmware/datastores_client.go | 88 +- .../datastores_client_example_test.go | 262 ------ .../connectedvmware/armconnectedvmware/go.mod | 20 +- .../connectedvmware/armconnectedvmware/go.sum | 38 +- .../armconnectedvmware/guestagents_client.go | 99 +- .../guestagents_client_example_test.go | 161 ---- .../armconnectedvmware/hosts_client.go | 88 +- .../hosts_client_example_test.go | 262 ------ .../hybrididentitymetadata_client.go | 87 +- ...rididentitymetadata_client_example_test.go | 159 ---- .../armconnectedvmware/interfaces.go | 28 + .../inventoryitems_client.go | 53 +- .../inventoryitems_client_example_test.go | 140 --- .../machineextensions_client.go | 180 ++-- .../machineextensions_client_example_test.go | 289 ------ .../armconnectedvmware/models.go | 884 ++++++++---------- .../armconnectedvmware/models_serde.go | 660 ++++++++++++- .../armconnectedvmware/operations_client.go | 6 +- .../operations_client_example_test.go | 244 ----- .../armconnectedvmware/options.go | 558 +++++++++++ .../armconnectedvmware/polymorphic_helpers.go | 7 +- .../resourcepools_client.go | 88 +- .../resourcepools_client_example_test.go | 262 ------ .../armconnectedvmware/response_types.go | 158 +++- .../armconnectedvmware/time_rfc3339.go | 2 +- .../armconnectedvmware/vcenters_client.go | 88 +- .../vcenters_client_example_test.go | 291 ------ .../virtualmachineinstances_client.go | 526 +++++++++++ .../virtualmachines_client.go | 325 ++++--- .../virtualmachines_client_example_test.go | 482 ---------- .../virtualmachinetemplates_client.go | 88 +- ...ualmachinetemplates_client_example_test.go | 262 ------ .../virtualnetworks_client.go | 88 +- .../virtualnetworks_client_example_test.go | 262 ------ .../vminstanceguestagents_client.go | 273 ++++++ ...vminstancehybrididentitymetadata_client.go | 155 +++ 43 files changed, 3796 insertions(+), 4504 deletions(-) create mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/azurearcvmwaremanagementserviceapi_client.go delete mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/clusters_client_example_test.go delete mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/datastores_client_example_test.go delete mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/guestagents_client_example_test.go delete mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/hosts_client_example_test.go delete mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/hybrididentitymetadata_client_example_test.go create mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/interfaces.go delete mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/inventoryitems_client_example_test.go delete mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/machineextensions_client_example_test.go delete mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/operations_client_example_test.go create mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/options.go delete mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/resourcepools_client_example_test.go delete mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/vcenters_client_example_test.go create mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachineinstances_client.go delete mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachines_client_example_test.go delete mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachinetemplates_client_example_test.go delete mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualnetworks_client_example_test.go create mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/vminstanceguestagents_client.go create mode 100644 sdk/resourcemanager/connectedvmware/armconnectedvmware/vminstancehybrididentitymetadata_client.go diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/CHANGELOG.md b/sdk/resourcemanager/connectedvmware/armconnectedvmware/CHANGELOG.md index 249ad7f1fa07..c9e5ef535566 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/CHANGELOG.md +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/CHANGELOG.md @@ -1,5 +1,89 @@ # Release History +## 0.3.0 (2023-08-08) +### Breaking Changes + +- Function `*VirtualMachinesClient.NewListPager` parameter(s) have been changed from `(*VirtualMachinesClientListOptions)` to `(string, *VirtualMachinesClientListOptions)` +- Type of `ClusterInventoryItem.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `ClusterProperties.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `DatastoreInventoryItem.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `GuestAgentProperties.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `HostInventoryItem.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `HostProperties.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `HybridIdentityMetadataProperties.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `InventoryItemProperties.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `ResourcePoolInventoryItem.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `ResourcePoolProperties.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `VCenterProperties.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `VirtualMachineInventoryItem.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `VirtualMachineProperties.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `VirtualMachineTemplateInventoryItem.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `VirtualMachineTemplateProperties.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `VirtualNetworkInventoryItem.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `VirtualNetworkProperties.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Function `*GuestAgentsClient.NewListByVMPager` has been removed +- Function `*HybridIdentityMetadataClient.NewListByVMPager` has been removed +- Function `*VirtualMachinesClient.BeginCreate` has been removed +- Function `*VirtualMachinesClient.NewListByResourceGroupPager` has been removed +- Field `Retain` of struct `VirtualMachinesClientBeginDeleteOptions` has been removed + +### Features Added + +- New function `NewAzureArcVMwareManagementServiceAPIClient(string, azcore.TokenCredential, *arm.ClientOptions) (*AzureArcVMwareManagementServiceAPIClient, error)` +- New function `*AzureArcVMwareManagementServiceAPIClient.BeginUpgradeExtensions(context.Context, string, string, MachineExtensionUpgrade, *AzureArcVMwareManagementServiceAPIClientBeginUpgradeExtensionsOptions) (*runtime.Poller[AzureArcVMwareManagementServiceAPIClientUpgradeExtensionsResponse], error)` +- New function `*ClientFactory.NewAzureArcVMwareManagementServiceAPIClient() *AzureArcVMwareManagementServiceAPIClient` +- New function `*ClientFactory.NewVMInstanceGuestAgentsClient() *VMInstanceGuestAgentsClient` +- New function `*ClientFactory.NewVMInstanceHybridIdentityMetadataClient() *VMInstanceHybridIdentityMetadataClient` +- New function `*ClientFactory.NewVirtualMachineInstancesClient() *VirtualMachineInstancesClient` +- New function `*GuestAgentsClient.NewListPager(string, string, *GuestAgentsClientListOptions) *runtime.Pager[GuestAgentsClientListResponse]` +- New function `*HybridIdentityMetadataClient.NewListPager(string, string, *HybridIdentityMetadataClientListOptions) *runtime.Pager[HybridIdentityMetadataClientListResponse]` +- New function `NewVMInstanceGuestAgentsClient(azcore.TokenCredential, *arm.ClientOptions) (*VMInstanceGuestAgentsClient, error)` +- New function `*VMInstanceGuestAgentsClient.BeginCreate(context.Context, string, GuestAgent, *VMInstanceGuestAgentsClientBeginCreateOptions) (*runtime.Poller[VMInstanceGuestAgentsClientCreateResponse], error)` +- New function `*VMInstanceGuestAgentsClient.BeginDelete(context.Context, string, *VMInstanceGuestAgentsClientBeginDeleteOptions) (*runtime.Poller[VMInstanceGuestAgentsClientDeleteResponse], error)` +- New function `*VMInstanceGuestAgentsClient.Get(context.Context, string, *VMInstanceGuestAgentsClientGetOptions) (VMInstanceGuestAgentsClientGetResponse, error)` +- New function `*VMInstanceGuestAgentsClient.NewListPager(string, *VMInstanceGuestAgentsClientListOptions) *runtime.Pager[VMInstanceGuestAgentsClientListResponse]` +- New function `NewVMInstanceHybridIdentityMetadataClient(azcore.TokenCredential, *arm.ClientOptions) (*VMInstanceHybridIdentityMetadataClient, error)` +- New function `*VMInstanceHybridIdentityMetadataClient.Get(context.Context, string, *VMInstanceHybridIdentityMetadataClientGetOptions) (VMInstanceHybridIdentityMetadataClientGetResponse, error)` +- New function `*VMInstanceHybridIdentityMetadataClient.NewListPager(string, *VMInstanceHybridIdentityMetadataClientListOptions) *runtime.Pager[VMInstanceHybridIdentityMetadataClientListResponse]` +- New function `NewVirtualMachineInstancesClient(azcore.TokenCredential, *arm.ClientOptions) (*VirtualMachineInstancesClient, error)` +- New function `*VirtualMachineInstancesClient.BeginCreateOrUpdate(context.Context, string, VirtualMachineInstance, *VirtualMachineInstancesClientBeginCreateOrUpdateOptions) (*runtime.Poller[VirtualMachineInstancesClientCreateOrUpdateResponse], error)` +- New function `*VirtualMachineInstancesClient.BeginDelete(context.Context, string, *VirtualMachineInstancesClientBeginDeleteOptions) (*runtime.Poller[VirtualMachineInstancesClientDeleteResponse], error)` +- New function `*VirtualMachineInstancesClient.Get(context.Context, string, *VirtualMachineInstancesClientGetOptions) (VirtualMachineInstancesClientGetResponse, error)` +- New function `*VirtualMachineInstancesClient.NewListPager(string, *VirtualMachineInstancesClientListOptions) *runtime.Pager[VirtualMachineInstancesClientListResponse]` +- New function `*VirtualMachineInstancesClient.BeginRestart(context.Context, string, *VirtualMachineInstancesClientBeginRestartOptions) (*runtime.Poller[VirtualMachineInstancesClientRestartResponse], error)` +- New function `*VirtualMachineInstancesClient.BeginStart(context.Context, string, *VirtualMachineInstancesClientBeginStartOptions) (*runtime.Poller[VirtualMachineInstancesClientStartResponse], error)` +- New function `*VirtualMachineInstancesClient.BeginStop(context.Context, string, *VirtualMachineInstancesClientBeginStopOptions) (*runtime.Poller[VirtualMachineInstancesClientStopResponse], error)` +- New function `*VirtualMachineInstancesClient.BeginUpdate(context.Context, string, VirtualMachineInstanceUpdate, *VirtualMachineInstancesClientBeginUpdateOptions) (*runtime.Poller[VirtualMachineInstancesClientUpdateResponse], error)` +- New function `*VirtualMachinesClient.BeginCreateOrUpdate(context.Context, string, string, VirtualMachine, *VirtualMachinesClientBeginCreateOrUpdateOptions) (*runtime.Poller[VirtualMachinesClientCreateOrUpdateResponse], error)` +- New function `*VirtualMachinesClient.NewListAllPager(*VirtualMachinesClientListAllOptions) *runtime.Pager[VirtualMachinesClientListAllResponse]` +- New struct `ErrorAdditionalInfo` +- New struct `ExtensionTargetProperties` +- New struct `GuestAgentProfileUpdate` +- New struct `InfrastructureProfile` +- New struct `MachineExtensionUpgrade` +- New struct `OsProfileForVMInstance` +- New struct `VMInstanceHybridIdentityMetadata` +- New struct `VMInstanceHybridIdentityMetadataList` +- New struct `VMInstanceHybridIdentityMetadataProperties` +- New struct `VirtualMachineInstance` +- New struct `VirtualMachineInstanceProperties` +- New struct `VirtualMachineInstanceUpdate` +- New struct `VirtualMachineInstanceUpdateProperties` +- New struct `VirtualMachineInstancesList` +- New field `TotalCPUMHz`, `TotalMemoryGB`, `UsedCPUMHz`, `UsedMemoryGB` in struct `ClusterProperties` +- New field `CapacityGB`, `FreeSpaceGB` in struct `DatastoreProperties` +- New field `AdditionalInfo` in struct `ErrorDetail` +- New field `ClientPublicKey`, `MssqlDiscovered` in struct `GuestAgentProfile` +- New field `PrivateLinkScopeResourceID` in struct `GuestAgentProperties` +- New field `CPUMhz`, `DatastoreIDs`, `MemorySizeGB`, `NetworkIDs`, `OverallCPUUsageMHz`, `OverallMemoryUsageGB` in struct `HostProperties` +- New field `InventoryType` in struct `InventoryItemDetails` +- New field `CPUCapacityMHz`, `CPUOverallUsageMHz`, `DatastoreIDs`, `MemCapacityGB`, `MemOverallUsageGB`, `NetworkIDs` in struct `ResourcePoolProperties` +- New field `Cluster` in struct `VirtualMachineInventoryItem` +- New field `ToolsVersion`, `ToolsVersionStatus` in struct `VirtualMachineTemplateInventoryItem` +- New field `GuestAgentProfile` in struct `VirtualMachineUpdateProperties` +- New field `DeleteFromHost` in struct `VirtualMachinesClientBeginDeleteOptions` + + ## 0.2.1 (2023-04-14) ### Bug Fixes diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/autorest.md b/sdk/resourcemanager/connectedvmware/armconnectedvmware/autorest.md index 35684bf13747..27a2338b8359 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/autorest.md +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/connectedvmware/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/connectedvmware/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.2.1 +module-version: 0.3.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/azurearcvmwaremanagementserviceapi_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/azurearcvmwaremanagementserviceapi_client.go new file mode 100644 index 000000000000..eab5ea4fce6b --- /dev/null +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/azurearcvmwaremanagementserviceapi_client.go @@ -0,0 +1,127 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package armconnectedvmware + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// AzureArcVMwareManagementServiceAPIClient contains the methods for the AzureArcVMwareManagementServiceAPI group. +// Don't use this type directly, use NewAzureArcVMwareManagementServiceAPIClient() instead. +type AzureArcVMwareManagementServiceAPIClient struct { + internal *arm.Client + subscriptionID string +} + +// NewAzureArcVMwareManagementServiceAPIClient creates a new instance of AzureArcVMwareManagementServiceAPIClient with the specified values. +// - subscriptionID - The Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAzureArcVMwareManagementServiceAPIClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AzureArcVMwareManagementServiceAPIClient, error) { + cl, err := arm.NewClient(moduleName+".AzureArcVMwareManagementServiceAPIClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &AzureArcVMwareManagementServiceAPIClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginUpgradeExtensions - The operation to Upgrade Machine Extensions. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The Resource Group Name. +// - virtualMachineName - The name of the machine containing the extension. +// - extensionUpgradeParameters - Parameters supplied to the Upgrade Extensions operation. +// - options - AzureArcVMwareManagementServiceAPIClientBeginUpgradeExtensionsOptions contains the optional parameters for the +// AzureArcVMwareManagementServiceAPIClient.BeginUpgradeExtensions method. +func (client *AzureArcVMwareManagementServiceAPIClient) BeginUpgradeExtensions(ctx context.Context, resourceGroupName string, virtualMachineName string, extensionUpgradeParameters MachineExtensionUpgrade, options *AzureArcVMwareManagementServiceAPIClientBeginUpgradeExtensionsOptions) (*runtime.Poller[AzureArcVMwareManagementServiceAPIClientUpgradeExtensionsResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.upgradeExtensions(ctx, resourceGroupName, virtualMachineName, extensionUpgradeParameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AzureArcVMwareManagementServiceAPIClientUpgradeExtensionsResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[AzureArcVMwareManagementServiceAPIClientUpgradeExtensionsResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// UpgradeExtensions - The operation to Upgrade Machine Extensions. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *AzureArcVMwareManagementServiceAPIClient) upgradeExtensions(ctx context.Context, resourceGroupName string, virtualMachineName string, extensionUpgradeParameters MachineExtensionUpgrade, options *AzureArcVMwareManagementServiceAPIClientBeginUpgradeExtensionsOptions) (*http.Response, error) { + var err error + req, err := client.upgradeExtensionsCreateRequest(ctx, resourceGroupName, virtualMachineName, extensionUpgradeParameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// upgradeExtensionsCreateRequest creates the UpgradeExtensions request. +func (client *AzureArcVMwareManagementServiceAPIClient) upgradeExtensionsCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, extensionUpgradeParameters MachineExtensionUpgrade, options *AzureArcVMwareManagementServiceAPIClientBeginUpgradeExtensionsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/upgradeExtensions" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if virtualMachineName == "" { + return nil, errors.New("parameter virtualMachineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, extensionUpgradeParameters); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/client_factory.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/client_factory.go index 3261996ebefe..e06344e7634b 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/client_factory.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/client_factory.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware @@ -46,23 +46,23 @@ func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, }, nil } -func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) +func (c *ClientFactory) NewAzureArcVMwareManagementServiceAPIClient() *AzureArcVMwareManagementServiceAPIClient { + subClient, _ := NewAzureArcVMwareManagementServiceAPIClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewVirtualMachinesClient() *VirtualMachinesClient { - subClient, _ := NewVirtualMachinesClient(c.subscriptionID, c.credential, c.options) +func (c *ClientFactory) NewClustersClient() *ClustersClient { + subClient, _ := NewClustersClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewResourcePoolsClient() *ResourcePoolsClient { - subClient, _ := NewResourcePoolsClient(c.subscriptionID, c.credential, c.options) +func (c *ClientFactory) NewDatastoresClient() *DatastoresClient { + subClient, _ := NewDatastoresClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewClustersClient() *ClustersClient { - subClient, _ := NewClustersClient(c.subscriptionID, c.credential, c.options) +func (c *ClientFactory) NewGuestAgentsClient() *GuestAgentsClient { + subClient, _ := NewGuestAgentsClient(c.subscriptionID, c.credential, c.options) return subClient } @@ -71,8 +71,28 @@ func (c *ClientFactory) NewHostsClient() *HostsClient { return subClient } -func (c *ClientFactory) NewDatastoresClient() *DatastoresClient { - subClient, _ := NewDatastoresClient(c.subscriptionID, c.credential, c.options) +func (c *ClientFactory) NewHybridIdentityMetadataClient() *HybridIdentityMetadataClient { + subClient, _ := NewHybridIdentityMetadataClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewInventoryItemsClient() *InventoryItemsClient { + subClient, _ := NewInventoryItemsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewMachineExtensionsClient() *MachineExtensionsClient { + subClient, _ := NewMachineExtensionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewResourcePoolsClient() *ResourcePoolsClient { + subClient, _ := NewResourcePoolsClient(c.subscriptionID, c.credential, c.options) return subClient } @@ -81,32 +101,32 @@ func (c *ClientFactory) NewVCentersClient() *VCentersClient { return subClient } -func (c *ClientFactory) NewVirtualMachineTemplatesClient() *VirtualMachineTemplatesClient { - subClient, _ := NewVirtualMachineTemplatesClient(c.subscriptionID, c.credential, c.options) +func (c *ClientFactory) NewVMInstanceGuestAgentsClient() *VMInstanceGuestAgentsClient { + subClient, _ := NewVMInstanceGuestAgentsClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewVirtualNetworksClient() *VirtualNetworksClient { - subClient, _ := NewVirtualNetworksClient(c.subscriptionID, c.credential, c.options) +func (c *ClientFactory) NewVMInstanceHybridIdentityMetadataClient() *VMInstanceHybridIdentityMetadataClient { + subClient, _ := NewVMInstanceHybridIdentityMetadataClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewInventoryItemsClient() *InventoryItemsClient { - subClient, _ := NewInventoryItemsClient(c.subscriptionID, c.credential, c.options) +func (c *ClientFactory) NewVirtualMachineInstancesClient() *VirtualMachineInstancesClient { + subClient, _ := NewVirtualMachineInstancesClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewHybridIdentityMetadataClient() *HybridIdentityMetadataClient { - subClient, _ := NewHybridIdentityMetadataClient(c.subscriptionID, c.credential, c.options) +func (c *ClientFactory) NewVirtualMachineTemplatesClient() *VirtualMachineTemplatesClient { + subClient, _ := NewVirtualMachineTemplatesClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewMachineExtensionsClient() *MachineExtensionsClient { - subClient, _ := NewMachineExtensionsClient(c.subscriptionID, c.credential, c.options) +func (c *ClientFactory) NewVirtualMachinesClient() *VirtualMachinesClient { + subClient, _ := NewVirtualMachinesClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewGuestAgentsClient() *GuestAgentsClient { - subClient, _ := NewGuestAgentsClient(c.subscriptionID, c.credential, c.options) +func (c *ClientFactory) NewVirtualNetworksClient() *VirtualNetworksClient { + subClient, _ := NewVirtualNetworksClient(c.subscriptionID, c.credential, c.options) return subClient } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/clusters_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/clusters_client.go index 2daa5ab0c1a1..98db1828a709 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/clusters_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/clusters_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware @@ -56,7 +56,7 @@ func NewClustersClient(subscriptionID string, credential azcore.TokenCredential, // BeginCreate - Create Or Update cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - clusterName - Name of the cluster. // - body - Request payload. @@ -67,9 +67,10 @@ func (client *ClustersClient) BeginCreate(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClustersClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClustersClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ClustersClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -78,20 +79,22 @@ func (client *ClustersClient) BeginCreate(ctx context.Context, resourceGroupName // Create - Create Or Update cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *ClustersClient) create(ctx context.Context, resourceGroupName string, clusterName string, body Cluster, options *ClustersClientBeginCreateOptions) (*http.Response, error) { + var err error req, err := client.createCreateRequest(ctx, resourceGroupName, clusterName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createCreateRequest creates the Create request. @@ -114,16 +117,19 @@ func (client *ClustersClient) createCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Implements cluster DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - clusterName - Name of the cluster. // - options - ClustersClientBeginDeleteOptions contains the optional parameters for the ClustersClient.BeginDelete method. @@ -133,7 +139,8 @@ func (client *ClustersClient) BeginDelete(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller[ClustersClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[ClustersClientDeleteResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[ClustersClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -142,20 +149,22 @@ func (client *ClustersClient) BeginDelete(ctx context.Context, resourceGroupName // Delete - Implements cluster DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *ClustersClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersClientBeginDeleteOptions) (*http.Response, error) { + var err error req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -178,7 +187,7 @@ func (client *ClustersClient) deleteCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") if options != nil && options.Force != nil { reqQP.Set("force", strconv.FormatBool(*options.Force)) } @@ -190,23 +199,26 @@ func (client *ClustersClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Implements cluster GET method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - clusterName - Name of the cluster. // - options - ClustersClientGetOptions contains the optional parameters for the ClustersClient.Get method. func (client *ClustersClient) Get(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersClientGetOptions) (ClustersClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, resourceGroupName, clusterName, options) if err != nil { return ClustersClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ClustersClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ClustersClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClustersClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -229,7 +241,7 @@ func (client *ClustersClient) getCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -246,7 +258,7 @@ func (client *ClustersClient) getHandleResponse(resp *http.Response) (ClustersCl // NewListPager - List of clusters in a subscription. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - options - ClustersClientListOptions contains the optional parameters for the ClustersClient.NewListPager method. func (client *ClustersClient) NewListPager(options *ClustersClientListOptions) *runtime.Pager[ClustersClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ClustersClientListResponse]{ @@ -288,7 +300,7 @@ func (client *ClustersClient) listCreateRequest(ctx context.Context, options *Cl return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -305,7 +317,7 @@ func (client *ClustersClient) listHandleResponse(resp *http.Response) (ClustersC // NewListByResourceGroupPager - List of clusters in a resource group. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - options - ClustersClientListByResourceGroupOptions contains the optional parameters for the ClustersClient.NewListByResourceGroupPager // method. @@ -353,7 +365,7 @@ func (client *ClustersClient) listByResourceGroupCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -371,24 +383,27 @@ func (client *ClustersClient) listByResourceGroupHandleResponse(resp *http.Respo // Update - API to update certain properties of the cluster resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - clusterName - Name of the cluster. // - body - Resource properties to update. // - options - ClustersClientUpdateOptions contains the optional parameters for the ClustersClient.Update method. func (client *ClustersClient) Update(ctx context.Context, resourceGroupName string, clusterName string, body ResourcePatch, options *ClustersClientUpdateOptions) (ClustersClientUpdateResponse, error) { + var err error req, err := client.updateCreateRequest(ctx, resourceGroupName, clusterName, body, options) if err != nil { return ClustersClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ClustersClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ClustersClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClustersClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -411,10 +426,13 @@ func (client *ClustersClient) updateCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // updateHandleResponse handles the Update response. diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/clusters_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/clusters_client_example_test.go deleted file mode 100644 index 3093b39c4786..000000000000 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/clusters_client_example_test.go +++ /dev/null @@ -1,262 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armconnectedvmware_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateCluster.json -func ExampleClustersClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewClustersClient().BeginCreate(ctx, "testrg", "HRCluster", armconnectedvmware.Cluster{ - ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - Type: to.Ptr("customLocation"), - }, - Location: to.Ptr("East US"), - Properties: &armconnectedvmware.ClusterProperties{ - MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Cluster = armconnectedvmware.Cluster{ - // Name: to.Ptr("HRCluster"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Clusters"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Clusters/HRCluster"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.ClusterProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetCluster.json -func ExampleClustersClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClustersClient().Get(ctx, "testrg", "HRCluster", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Cluster = armconnectedvmware.Cluster{ - // Name: to.Ptr("HRCluster"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Clusters"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Clusters/HRCluster"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.ClusterProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateCluster.json -func ExampleClustersClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClustersClient().Update(ctx, "testrg", "HRCluster", armconnectedvmware.ResourcePatch{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Cluster = armconnectedvmware.Cluster{ - // Name: to.Ptr("HRCluster"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Clusters"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Clusters/HRCluster"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.ClusterProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteCluster.json -func ExampleClustersClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewClustersClient().BeginDelete(ctx, "testrg", "HRCluster", &armconnectedvmware.ClustersClientBeginDeleteOptions{Force: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListClusters.json -func ExampleClustersClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClustersClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ClustersList = armconnectedvmware.ClustersList{ - // Value: []*armconnectedvmware.Cluster{ - // { - // Name: to.Ptr("HRCluster"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Clusters"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Clusters/HRCluster"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.ClusterProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListClustersByResourceGroup.json -func ExampleClustersClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClustersClient().NewListByResourceGroupPager("testrg", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ClustersList = armconnectedvmware.ClustersList{ - // Value: []*armconnectedvmware.Cluster{ - // { - // Name: to.Ptr("HRCluster"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Clusters"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Clusters/HRCluster"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.ClusterProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/constants.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/constants.go index 0c2ea210e540..ab8cfc4ba7f7 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/constants.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/constants.go @@ -13,13 +13,13 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware const ( moduleName = "armconnectedvmware" - moduleVersion = "v0.2.1" + moduleVersion = "v0.3.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/datastores_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/datastores_client.go index 254dedfb7f77..bb7d8f8ac9ff 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/datastores_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/datastores_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware @@ -56,7 +56,7 @@ func NewDatastoresClient(subscriptionID string, credential azcore.TokenCredentia // BeginCreate - Create Or Update datastore. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - datastoreName - Name of the datastore. // - body - Request payload. @@ -67,9 +67,10 @@ func (client *DatastoresClient) BeginCreate(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DatastoresClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DatastoresClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[DatastoresClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -78,20 +79,22 @@ func (client *DatastoresClient) BeginCreate(ctx context.Context, resourceGroupNa // Create - Create Or Update datastore. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *DatastoresClient) create(ctx context.Context, resourceGroupName string, datastoreName string, body Datastore, options *DatastoresClientBeginCreateOptions) (*http.Response, error) { + var err error req, err := client.createCreateRequest(ctx, resourceGroupName, datastoreName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createCreateRequest creates the Create request. @@ -114,16 +117,19 @@ func (client *DatastoresClient) createCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Implements datastore DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - datastoreName - Name of the datastore. // - options - DatastoresClientBeginDeleteOptions contains the optional parameters for the DatastoresClient.BeginDelete method. @@ -133,7 +139,8 @@ func (client *DatastoresClient) BeginDelete(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - return runtime.NewPoller[DatastoresClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[DatastoresClientDeleteResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[DatastoresClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -142,20 +149,22 @@ func (client *DatastoresClient) BeginDelete(ctx context.Context, resourceGroupNa // Delete - Implements datastore DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *DatastoresClient) deleteOperation(ctx context.Context, resourceGroupName string, datastoreName string, options *DatastoresClientBeginDeleteOptions) (*http.Response, error) { + var err error req, err := client.deleteCreateRequest(ctx, resourceGroupName, datastoreName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -178,7 +187,7 @@ func (client *DatastoresClient) deleteCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") if options != nil && options.Force != nil { reqQP.Set("force", strconv.FormatBool(*options.Force)) } @@ -190,23 +199,26 @@ func (client *DatastoresClient) deleteCreateRequest(ctx context.Context, resourc // Get - Implements datastore GET method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - datastoreName - Name of the datastore. // - options - DatastoresClientGetOptions contains the optional parameters for the DatastoresClient.Get method. func (client *DatastoresClient) Get(ctx context.Context, resourceGroupName string, datastoreName string, options *DatastoresClientGetOptions) (DatastoresClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, resourceGroupName, datastoreName, options) if err != nil { return DatastoresClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DatastoresClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DatastoresClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DatastoresClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -229,7 +241,7 @@ func (client *DatastoresClient) getCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -246,7 +258,7 @@ func (client *DatastoresClient) getHandleResponse(resp *http.Response) (Datastor // NewListPager - List of datastores in a subscription. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - options - DatastoresClientListOptions contains the optional parameters for the DatastoresClient.NewListPager method. func (client *DatastoresClient) NewListPager(options *DatastoresClientListOptions) *runtime.Pager[DatastoresClientListResponse] { return runtime.NewPager(runtime.PagingHandler[DatastoresClientListResponse]{ @@ -288,7 +300,7 @@ func (client *DatastoresClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -305,7 +317,7 @@ func (client *DatastoresClient) listHandleResponse(resp *http.Response) (Datasto // NewListByResourceGroupPager - List of datastores in a resource group. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - options - DatastoresClientListByResourceGroupOptions contains the optional parameters for the DatastoresClient.NewListByResourceGroupPager // method. @@ -353,7 +365,7 @@ func (client *DatastoresClient) listByResourceGroupCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -371,24 +383,27 @@ func (client *DatastoresClient) listByResourceGroupHandleResponse(resp *http.Res // Update - API to update certain properties of the datastore resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - datastoreName - Name of the datastore. // - body - Resource properties to update. // - options - DatastoresClientUpdateOptions contains the optional parameters for the DatastoresClient.Update method. func (client *DatastoresClient) Update(ctx context.Context, resourceGroupName string, datastoreName string, body ResourcePatch, options *DatastoresClientUpdateOptions) (DatastoresClientUpdateResponse, error) { + var err error req, err := client.updateCreateRequest(ctx, resourceGroupName, datastoreName, body, options) if err != nil { return DatastoresClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DatastoresClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DatastoresClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DatastoresClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -411,10 +426,13 @@ func (client *DatastoresClient) updateCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // updateHandleResponse handles the Update response. diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/datastores_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/datastores_client_example_test.go deleted file mode 100644 index a4df9a0ed3b7..000000000000 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/datastores_client_example_test.go +++ /dev/null @@ -1,262 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armconnectedvmware_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateDatastore.json -func ExampleDatastoresClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDatastoresClient().BeginCreate(ctx, "testrg", "HRDatastore", armconnectedvmware.Datastore{ - ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - Type: to.Ptr("customLocation"), - }, - Location: to.Ptr("East US"), - Properties: &armconnectedvmware.DatastoreProperties{ - MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Datastore = armconnectedvmware.Datastore{ - // Name: to.Ptr("HRDatastore"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Datastores"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Datastores/HRDatastore"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.DatastoreProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr(armconnectedvmware.ProvisioningStateSucceeded), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetDatastore.json -func ExampleDatastoresClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDatastoresClient().Get(ctx, "testrg", "HRDatastore", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Datastore = armconnectedvmware.Datastore{ - // Name: to.Ptr("HRDatastore"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Datastores"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Datastores/HRDatastore"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.DatastoreProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr(armconnectedvmware.ProvisioningStateSucceeded), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateDatastore.json -func ExampleDatastoresClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDatastoresClient().Update(ctx, "testrg", "HRDatastore", armconnectedvmware.ResourcePatch{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Datastore = armconnectedvmware.Datastore{ - // Name: to.Ptr("HRDatastore"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Datastores"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Datastores/HRDatastore"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.DatastoreProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr(armconnectedvmware.ProvisioningStateSucceeded), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteDatastore.json -func ExampleDatastoresClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDatastoresClient().BeginDelete(ctx, "testrg", "HRDatastore", &armconnectedvmware.DatastoresClientBeginDeleteOptions{Force: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListDatastores.json -func ExampleDatastoresClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDatastoresClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DatastoresList = armconnectedvmware.DatastoresList{ - // Value: []*armconnectedvmware.Datastore{ - // { - // Name: to.Ptr("HRDatastore"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Datastores"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Datastores/HRDatastore"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.DatastoreProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr(armconnectedvmware.ProvisioningStateSucceeded), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListDatastoresByResourceGroup.json -func ExampleDatastoresClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDatastoresClient().NewListByResourceGroupPager("testrg", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DatastoresList = armconnectedvmware.DatastoresList{ - // Value: []*armconnectedvmware.Datastore{ - // { - // Name: to.Ptr("HRDatastore"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Datastores"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Datastores/HRDatastore"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.DatastoreProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr(armconnectedvmware.ProvisioningStateSucceeded), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/go.mod b/sdk/resourcemanager/connectedvmware/armconnectedvmware/go.mod index 7bcb16f2fc98..11f7063c555f 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/go.mod +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/go.mod @@ -2,20 +2,12 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/arm go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.6.0 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + golang.org/x/net v0.8.0 // indirect + golang.org/x/text v0.8.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/go.sum b/sdk/resourcemanager/connectedvmware/armconnectedvmware/go.sum index 8ba445a8c4da..5c6bee428364 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/go.sum +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/go.sum @@ -1,31 +1,15 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/guestagents_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/guestagents_client.go index b694e4615a63..f6dcd99ba30f 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/guestagents_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/guestagents_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware @@ -55,7 +55,7 @@ func NewGuestAgentsClient(subscriptionID string, credential azcore.TokenCredenti // BeginCreate - Create Or Update GuestAgent. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineName - Name of the vm. // - name - Name of the guestAgents. @@ -67,9 +67,10 @@ func (client *GuestAgentsClient) BeginCreate(ctx context.Context, resourceGroupN if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GuestAgentsClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GuestAgentsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[GuestAgentsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -78,20 +79,22 @@ func (client *GuestAgentsClient) BeginCreate(ctx context.Context, resourceGroupN // Create - Create Or Update GuestAgent. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *GuestAgentsClient) create(ctx context.Context, resourceGroupName string, virtualMachineName string, name string, body GuestAgent, options *GuestAgentsClientBeginCreateOptions) (*http.Response, error) { + var err error req, err := client.createCreateRequest(ctx, resourceGroupName, virtualMachineName, name, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createCreateRequest creates the Create request. @@ -118,16 +121,19 @@ func (client *GuestAgentsClient) createCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Implements GuestAgent DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineName - Name of the vm. // - name - Name of the GuestAgent. @@ -138,7 +144,8 @@ func (client *GuestAgentsClient) BeginDelete(ctx context.Context, resourceGroupN if err != nil { return nil, err } - return runtime.NewPoller[GuestAgentsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[GuestAgentsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[GuestAgentsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -147,20 +154,22 @@ func (client *GuestAgentsClient) BeginDelete(ctx context.Context, resourceGroupN // Delete - Implements GuestAgent DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *GuestAgentsClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualMachineName string, name string, options *GuestAgentsClientBeginDeleteOptions) (*http.Response, error) { + var err error req, err := client.deleteCreateRequest(ctx, resourceGroupName, virtualMachineName, name, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -187,7 +196,7 @@ func (client *GuestAgentsClient) deleteCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -196,24 +205,27 @@ func (client *GuestAgentsClient) deleteCreateRequest(ctx context.Context, resour // Get - Implements GuestAgent GET method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineName - Name of the vm. // - name - Name of the GuestAgent. // - options - GuestAgentsClientGetOptions contains the optional parameters for the GuestAgentsClient.Get method. func (client *GuestAgentsClient) Get(ctx context.Context, resourceGroupName string, virtualMachineName string, name string, options *GuestAgentsClientGetOptions) (GuestAgentsClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, resourceGroupName, virtualMachineName, name, options) if err != nil { return GuestAgentsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return GuestAgentsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return GuestAgentsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return GuestAgentsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -240,7 +252,7 @@ func (client *GuestAgentsClient) getCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -255,43 +267,42 @@ func (client *GuestAgentsClient) getHandleResponse(resp *http.Response) (GuestAg return result, nil } -// NewListByVMPager - Returns the list of GuestAgent of the given vm. +// NewListPager - Returns the list of GuestAgent of the given vm. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineName - Name of the vm. -// - options - GuestAgentsClientListByVMOptions contains the optional parameters for the GuestAgentsClient.NewListByVMPager -// method. -func (client *GuestAgentsClient) NewListByVMPager(resourceGroupName string, virtualMachineName string, options *GuestAgentsClientListByVMOptions) *runtime.Pager[GuestAgentsClientListByVMResponse] { - return runtime.NewPager(runtime.PagingHandler[GuestAgentsClientListByVMResponse]{ - More: func(page GuestAgentsClientListByVMResponse) bool { +// - options - GuestAgentsClientListOptions contains the optional parameters for the GuestAgentsClient.NewListPager method. +func (client *GuestAgentsClient) NewListPager(resourceGroupName string, virtualMachineName string, options *GuestAgentsClientListOptions) *runtime.Pager[GuestAgentsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[GuestAgentsClientListResponse]{ + More: func(page GuestAgentsClientListResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *GuestAgentsClientListByVMResponse) (GuestAgentsClientListByVMResponse, error) { + Fetcher: func(ctx context.Context, page *GuestAgentsClientListResponse) (GuestAgentsClientListResponse, error) { var req *policy.Request var err error if page == nil { - req, err = client.listByVMCreateRequest(ctx, resourceGroupName, virtualMachineName, options) + req, err = client.listCreateRequest(ctx, resourceGroupName, virtualMachineName, options) } else { req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) } if err != nil { - return GuestAgentsClientListByVMResponse{}, err + return GuestAgentsClientListResponse{}, err } resp, err := client.internal.Pipeline().Do(req) if err != nil { - return GuestAgentsClientListByVMResponse{}, err + return GuestAgentsClientListResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return GuestAgentsClientListByVMResponse{}, runtime.NewResponseError(resp) + return GuestAgentsClientListResponse{}, runtime.NewResponseError(resp) } - return client.listByVMHandleResponse(resp) + return client.listHandleResponse(resp) }, }) } -// listByVMCreateRequest creates the ListByVM request. -func (client *GuestAgentsClient) listByVMCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *GuestAgentsClientListByVMOptions) (*policy.Request, error) { +// listCreateRequest creates the List request. +func (client *GuestAgentsClient) listCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *GuestAgentsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -310,17 +321,17 @@ func (client *GuestAgentsClient) listByVMCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// listByVMHandleResponse handles the ListByVM response. -func (client *GuestAgentsClient) listByVMHandleResponse(resp *http.Response) (GuestAgentsClientListByVMResponse, error) { - result := GuestAgentsClientListByVMResponse{} +// listHandleResponse handles the List response. +func (client *GuestAgentsClient) listHandleResponse(resp *http.Response) (GuestAgentsClientListResponse, error) { + result := GuestAgentsClientListResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.GuestAgentList); err != nil { - return GuestAgentsClientListByVMResponse{}, err + return GuestAgentsClientListResponse{}, err } return result, nil } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/guestagents_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/guestagents_client_example_test.go deleted file mode 100644 index f00920289a12..000000000000 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/guestagents_client_example_test.go +++ /dev/null @@ -1,161 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armconnectedvmware_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateGuestAgent.json -func ExampleGuestAgentsClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGuestAgentsClient().BeginCreate(ctx, "testrg", "ContosoVm", "default", armconnectedvmware.GuestAgent{ - Properties: &armconnectedvmware.GuestAgentProperties{ - Credentials: &armconnectedvmware.GuestCredential{ - Password: to.Ptr(""), - Username: to.Ptr("tempuser"), - }, - HTTPProxyConfig: &armconnectedvmware.HTTPProxyConfiguration{ - HTTPSProxy: to.Ptr("http://192.1.2.3:8080"), - }, - ProvisioningAction: to.Ptr(armconnectedvmware.ProvisioningActionInstall), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.GuestAgent = armconnectedvmware.GuestAgent{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VitualMachines/guestAgents"), - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VitualMachines/ContosoVm/guestAgents/default"), - // Properties: &armconnectedvmware.GuestAgentProperties{ - // ProvisioningAction: to.Ptr(armconnectedvmware.ProvisioningActionInstall), - // ProvisioningState: to.Ptr("Succeeded"), - // Status: to.Ptr("connected"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetGuestAgent.json -func ExampleGuestAgentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGuestAgentsClient().Get(ctx, "testrg", "ContosoVm", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.GuestAgent = armconnectedvmware.GuestAgent{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VitualMachines/guestAgents"), - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VitualMachines/ContosoVm/guestAgents/default"), - // Properties: &armconnectedvmware.GuestAgentProperties{ - // ProvisioningAction: to.Ptr(armconnectedvmware.ProvisioningActionInstall), - // ProvisioningState: to.Ptr("Succeeded"), - // Status: to.Ptr("connected"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteGuestAgent.json -func ExampleGuestAgentsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGuestAgentsClient().BeginDelete(ctx, "testrg", "ContosoVm", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GuestAgent_ListByVm.json -func ExampleGuestAgentsClient_NewListByVMPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewGuestAgentsClient().NewListByVMPager("testrg", "ContosoVm", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.GuestAgentList = armconnectedvmware.GuestAgentList{ - // Value: []*armconnectedvmware.GuestAgent{ - // { - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VitualMachines/guestAgents"), - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VitualMachines/ContosoVm/guestAgents/default"), - // Properties: &armconnectedvmware.GuestAgentProperties{ - // ProvisioningAction: to.Ptr(armconnectedvmware.ProvisioningActionInstall), - // ProvisioningState: to.Ptr("Succeeded"), - // Status: to.Ptr("connected"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/hosts_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/hosts_client.go index 919a384f65c4..2704642c5941 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/hosts_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/hosts_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware @@ -56,7 +56,7 @@ func NewHostsClient(subscriptionID string, credential azcore.TokenCredential, op // BeginCreate - Create Or Update host. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - hostName - Name of the host. // - body - Request payload. @@ -67,9 +67,10 @@ func (client *HostsClient) BeginCreate(ctx context.Context, resourceGroupName st if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[HostsClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[HostsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[HostsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -78,20 +79,22 @@ func (client *HostsClient) BeginCreate(ctx context.Context, resourceGroupName st // Create - Create Or Update host. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *HostsClient) create(ctx context.Context, resourceGroupName string, hostName string, body Host, options *HostsClientBeginCreateOptions) (*http.Response, error) { + var err error req, err := client.createCreateRequest(ctx, resourceGroupName, hostName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createCreateRequest creates the Create request. @@ -114,16 +117,19 @@ func (client *HostsClient) createCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Implements host DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - hostName - Name of the host. // - options - HostsClientBeginDeleteOptions contains the optional parameters for the HostsClient.BeginDelete method. @@ -133,7 +139,8 @@ func (client *HostsClient) BeginDelete(ctx context.Context, resourceGroupName st if err != nil { return nil, err } - return runtime.NewPoller[HostsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[HostsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[HostsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -142,20 +149,22 @@ func (client *HostsClient) BeginDelete(ctx context.Context, resourceGroupName st // Delete - Implements host DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *HostsClient) deleteOperation(ctx context.Context, resourceGroupName string, hostName string, options *HostsClientBeginDeleteOptions) (*http.Response, error) { + var err error req, err := client.deleteCreateRequest(ctx, resourceGroupName, hostName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -178,7 +187,7 @@ func (client *HostsClient) deleteCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") if options != nil && options.Force != nil { reqQP.Set("force", strconv.FormatBool(*options.Force)) } @@ -190,23 +199,26 @@ func (client *HostsClient) deleteCreateRequest(ctx context.Context, resourceGrou // Get - Implements host GET method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - hostName - Name of the host. // - options - HostsClientGetOptions contains the optional parameters for the HostsClient.Get method. func (client *HostsClient) Get(ctx context.Context, resourceGroupName string, hostName string, options *HostsClientGetOptions) (HostsClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, resourceGroupName, hostName, options) if err != nil { return HostsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return HostsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return HostsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return HostsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -229,7 +241,7 @@ func (client *HostsClient) getCreateRequest(ctx context.Context, resourceGroupNa return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -246,7 +258,7 @@ func (client *HostsClient) getHandleResponse(resp *http.Response) (HostsClientGe // NewListPager - List of hosts in a subscription. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - options - HostsClientListOptions contains the optional parameters for the HostsClient.NewListPager method. func (client *HostsClient) NewListPager(options *HostsClientListOptions) *runtime.Pager[HostsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[HostsClientListResponse]{ @@ -288,7 +300,7 @@ func (client *HostsClient) listCreateRequest(ctx context.Context, options *Hosts return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -305,7 +317,7 @@ func (client *HostsClient) listHandleResponse(resp *http.Response) (HostsClientL // NewListByResourceGroupPager - List of hosts in a resource group. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - options - HostsClientListByResourceGroupOptions contains the optional parameters for the HostsClient.NewListByResourceGroupPager // method. @@ -353,7 +365,7 @@ func (client *HostsClient) listByResourceGroupCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -371,24 +383,27 @@ func (client *HostsClient) listByResourceGroupHandleResponse(resp *http.Response // Update - API to update certain properties of the host resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - hostName - Name of the host. // - body - Resource properties to update. // - options - HostsClientUpdateOptions contains the optional parameters for the HostsClient.Update method. func (client *HostsClient) Update(ctx context.Context, resourceGroupName string, hostName string, body ResourcePatch, options *HostsClientUpdateOptions) (HostsClientUpdateResponse, error) { + var err error req, err := client.updateCreateRequest(ctx, resourceGroupName, hostName, body, options) if err != nil { return HostsClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return HostsClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return HostsClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return HostsClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -411,10 +426,13 @@ func (client *HostsClient) updateCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // updateHandleResponse handles the Update response. diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/hosts_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/hosts_client_example_test.go deleted file mode 100644 index c802a27f39e6..000000000000 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/hosts_client_example_test.go +++ /dev/null @@ -1,262 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armconnectedvmware_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateHost.json -func ExampleHostsClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewHostsClient().BeginCreate(ctx, "testrg", "HRHost", armconnectedvmware.Host{ - ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - Type: to.Ptr("customLocation"), - }, - Location: to.Ptr("East US"), - Properties: &armconnectedvmware.HostProperties{ - MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Host = armconnectedvmware.Host{ - // Name: to.Ptr("HRHost"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Hosts"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Hosts/HRHost"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.HostProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetHost.json -func ExampleHostsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewHostsClient().Get(ctx, "testrg", "HRHost", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Host = armconnectedvmware.Host{ - // Name: to.Ptr("HRHost"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Hosts"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Hosts/HRHost"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.HostProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateHost.json -func ExampleHostsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewHostsClient().Update(ctx, "testrg", "HRHost", armconnectedvmware.ResourcePatch{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Host = armconnectedvmware.Host{ - // Name: to.Ptr("HRHost"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Hosts"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Hosts/HRHost"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.HostProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteHost.json -func ExampleHostsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewHostsClient().BeginDelete(ctx, "testrg", "HRHost", &armconnectedvmware.HostsClientBeginDeleteOptions{Force: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListHosts.json -func ExampleHostsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewHostsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.HostsList = armconnectedvmware.HostsList{ - // Value: []*armconnectedvmware.Host{ - // { - // Name: to.Ptr("HRHost"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Hosts"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Hosts/HRHost"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.HostProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListHostsByResourceGroup.json -func ExampleHostsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewHostsClient().NewListByResourceGroupPager("testrg", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.HostsList = armconnectedvmware.HostsList{ - // Value: []*armconnectedvmware.Host{ - // { - // Name: to.Ptr("HRHost"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/Hosts"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/Hosts/HRHost"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.HostProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/hybrididentitymetadata_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/hybrididentitymetadata_client.go index 5b1aaf0dc2d2..7bd79aa9ab35 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/hybrididentitymetadata_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/hybrididentitymetadata_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware @@ -55,7 +55,7 @@ func NewHybridIdentityMetadataClient(subscriptionID string, credential azcore.To // Create - Create Or Update HybridIdentityMetadata. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineName - Name of the vm. // - metadataName - Name of the hybridIdentityMetadata. @@ -63,18 +63,21 @@ func NewHybridIdentityMetadataClient(subscriptionID string, credential azcore.To // - options - HybridIdentityMetadataClientCreateOptions contains the optional parameters for the HybridIdentityMetadataClient.Create // method. func (client *HybridIdentityMetadataClient) Create(ctx context.Context, resourceGroupName string, virtualMachineName string, metadataName string, body HybridIdentityMetadata, options *HybridIdentityMetadataClientCreateOptions) (HybridIdentityMetadataClientCreateResponse, error) { + var err error req, err := client.createCreateRequest(ctx, resourceGroupName, virtualMachineName, metadataName, body, options) if err != nil { return HybridIdentityMetadataClientCreateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return HybridIdentityMetadataClientCreateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return HybridIdentityMetadataClientCreateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return HybridIdentityMetadataClientCreateResponse{}, err } - return client.createHandleResponse(resp) + resp, err := client.createHandleResponse(httpResp) + return resp, err } // createCreateRequest creates the Create request. @@ -101,10 +104,13 @@ func (client *HybridIdentityMetadataClient) createCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // createHandleResponse handles the Create response. @@ -119,23 +125,25 @@ func (client *HybridIdentityMetadataClient) createHandleResponse(resp *http.Resp // Delete - Implements HybridIdentityMetadata DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineName - Name of the vm. // - metadataName - Name of the HybridIdentityMetadata. // - options - HybridIdentityMetadataClientDeleteOptions contains the optional parameters for the HybridIdentityMetadataClient.Delete // method. func (client *HybridIdentityMetadataClient) Delete(ctx context.Context, resourceGroupName string, virtualMachineName string, metadataName string, options *HybridIdentityMetadataClientDeleteOptions) (HybridIdentityMetadataClientDeleteResponse, error) { + var err error req, err := client.deleteCreateRequest(ctx, resourceGroupName, virtualMachineName, metadataName, options) if err != nil { return HybridIdentityMetadataClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return HybridIdentityMetadataClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return HybridIdentityMetadataClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return HybridIdentityMetadataClientDeleteResponse{}, err } return HybridIdentityMetadataClientDeleteResponse{}, nil } @@ -164,7 +172,7 @@ func (client *HybridIdentityMetadataClient) deleteCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -173,25 +181,28 @@ func (client *HybridIdentityMetadataClient) deleteCreateRequest(ctx context.Cont // Get - Implements HybridIdentityMetadata GET method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineName - Name of the vm. // - metadataName - Name of the HybridIdentityMetadata. // - options - HybridIdentityMetadataClientGetOptions contains the optional parameters for the HybridIdentityMetadataClient.Get // method. func (client *HybridIdentityMetadataClient) Get(ctx context.Context, resourceGroupName string, virtualMachineName string, metadataName string, options *HybridIdentityMetadataClientGetOptions) (HybridIdentityMetadataClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, resourceGroupName, virtualMachineName, metadataName, options) if err != nil { return HybridIdentityMetadataClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return HybridIdentityMetadataClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return HybridIdentityMetadataClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return HybridIdentityMetadataClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -218,7 +229,7 @@ func (client *HybridIdentityMetadataClient) getCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -233,43 +244,43 @@ func (client *HybridIdentityMetadataClient) getHandleResponse(resp *http.Respons return result, nil } -// NewListByVMPager - Returns the list of HybridIdentityMetadata of the given vm. +// NewListPager - Returns the list of HybridIdentityMetadata of the given vm. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineName - Name of the vm. -// - options - HybridIdentityMetadataClientListByVMOptions contains the optional parameters for the HybridIdentityMetadataClient.NewListByVMPager +// - options - HybridIdentityMetadataClientListOptions contains the optional parameters for the HybridIdentityMetadataClient.NewListPager // method. -func (client *HybridIdentityMetadataClient) NewListByVMPager(resourceGroupName string, virtualMachineName string, options *HybridIdentityMetadataClientListByVMOptions) *runtime.Pager[HybridIdentityMetadataClientListByVMResponse] { - return runtime.NewPager(runtime.PagingHandler[HybridIdentityMetadataClientListByVMResponse]{ - More: func(page HybridIdentityMetadataClientListByVMResponse) bool { +func (client *HybridIdentityMetadataClient) NewListPager(resourceGroupName string, virtualMachineName string, options *HybridIdentityMetadataClientListOptions) *runtime.Pager[HybridIdentityMetadataClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[HybridIdentityMetadataClientListResponse]{ + More: func(page HybridIdentityMetadataClientListResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *HybridIdentityMetadataClientListByVMResponse) (HybridIdentityMetadataClientListByVMResponse, error) { + Fetcher: func(ctx context.Context, page *HybridIdentityMetadataClientListResponse) (HybridIdentityMetadataClientListResponse, error) { var req *policy.Request var err error if page == nil { - req, err = client.listByVMCreateRequest(ctx, resourceGroupName, virtualMachineName, options) + req, err = client.listCreateRequest(ctx, resourceGroupName, virtualMachineName, options) } else { req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) } if err != nil { - return HybridIdentityMetadataClientListByVMResponse{}, err + return HybridIdentityMetadataClientListResponse{}, err } resp, err := client.internal.Pipeline().Do(req) if err != nil { - return HybridIdentityMetadataClientListByVMResponse{}, err + return HybridIdentityMetadataClientListResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return HybridIdentityMetadataClientListByVMResponse{}, runtime.NewResponseError(resp) + return HybridIdentityMetadataClientListResponse{}, runtime.NewResponseError(resp) } - return client.listByVMHandleResponse(resp) + return client.listHandleResponse(resp) }, }) } -// listByVMCreateRequest creates the ListByVM request. -func (client *HybridIdentityMetadataClient) listByVMCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *HybridIdentityMetadataClientListByVMOptions) (*policy.Request, error) { +// listCreateRequest creates the List request. +func (client *HybridIdentityMetadataClient) listCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *HybridIdentityMetadataClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -288,17 +299,17 @@ func (client *HybridIdentityMetadataClient) listByVMCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// listByVMHandleResponse handles the ListByVM response. -func (client *HybridIdentityMetadataClient) listByVMHandleResponse(resp *http.Response) (HybridIdentityMetadataClientListByVMResponse, error) { - result := HybridIdentityMetadataClientListByVMResponse{} +// listHandleResponse handles the List response. +func (client *HybridIdentityMetadataClient) listHandleResponse(resp *http.Response) (HybridIdentityMetadataClientListResponse, error) { + result := HybridIdentityMetadataClientListResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.HybridIdentityMetadataList); err != nil { - return HybridIdentityMetadataClientListByVMResponse{}, err + return HybridIdentityMetadataClientListResponse{}, err } return result, nil } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/hybrididentitymetadata_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/hybrididentitymetadata_client_example_test.go deleted file mode 100644 index 5a197feda9df..000000000000 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/hybrididentitymetadata_client_example_test.go +++ /dev/null @@ -1,159 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armconnectedvmware_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateHybridIdentityMetadata.json -func ExampleHybridIdentityMetadataClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewHybridIdentityMetadataClient().Create(ctx, "testrg", "ContosoVm", "default", armconnectedvmware.HybridIdentityMetadata{ - Properties: &armconnectedvmware.HybridIdentityMetadataProperties{ - PublicKey: to.Ptr("8ec7d60c-9700-40b1-8e6e-e5b2f6f477f2"), - VMID: to.Ptr("f8b82dff-38ef-4220-99ef-d3a3f86ddc6c"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.HybridIdentityMetadata = armconnectedvmware.HybridIdentityMetadata{ - // Name: to.Ptr("testItem"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VitualMachines/hybridIdentityMetadatas"), - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VitualMachines/ContosoVm/hybridIdentityMetadatas/default"), - // Properties: &armconnectedvmware.HybridIdentityMetadataProperties{ - // Identity: &armconnectedvmware.Identity{ - // Type: to.Ptr(armconnectedvmware.IdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("7b5129bc-8642-4a6a-95f8-63400ca6ec4d"), - // TenantID: to.Ptr("ec46ca82-5d4a-4e3e-b4b7-e27f9318645d"), - // }, - // PublicKey: to.Ptr("8ec7d60c-9700-40b1-8e6e-e5b2f6f477f2"), - // VMID: to.Ptr("f8b82dff-38ef-4220-99ef-d3a3f86ddc6c"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetHybridIdentityMetadata.json -func ExampleHybridIdentityMetadataClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewHybridIdentityMetadataClient().Get(ctx, "testrg", "ContosoVm", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.HybridIdentityMetadata = armconnectedvmware.HybridIdentityMetadata{ - // Name: to.Ptr("testItem"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VitualMachines/hybridIdentityMetadatas"), - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VitualMachines/ContosoVm/hybridIdentityMetadatas/default"), - // Properties: &armconnectedvmware.HybridIdentityMetadataProperties{ - // Identity: &armconnectedvmware.Identity{ - // Type: to.Ptr(armconnectedvmware.IdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("7b5129bc-8642-4a6a-95f8-63400ca6ec4d"), - // TenantID: to.Ptr("ec46ca82-5d4a-4e3e-b4b7-e27f9318645d"), - // }, - // PublicKey: to.Ptr("8ec7d60c-9700-40b1-8e6e-e5b2f6f477f2"), - // VMID: to.Ptr("f8b82dff-38ef-4220-99ef-d3a3f86ddc6c"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteHybridIdentityMetadata.json -func ExampleHybridIdentityMetadataClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewHybridIdentityMetadataClient().Delete(ctx, "testrg", "ContosoVm", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/HybridIdentityMetadata_ListByVm.json -func ExampleHybridIdentityMetadataClient_NewListByVMPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewHybridIdentityMetadataClient().NewListByVMPager("testrg", "ContosoVm", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.HybridIdentityMetadataList = armconnectedvmware.HybridIdentityMetadataList{ - // Value: []*armconnectedvmware.HybridIdentityMetadata{ - // { - // Name: to.Ptr("testItem"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VitualMachines/hybridIdentityMetadatas"), - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VitualMachines/ContosoVm/hybridIdentityMetadatas/default"), - // Properties: &armconnectedvmware.HybridIdentityMetadataProperties{ - // Identity: &armconnectedvmware.Identity{ - // Type: to.Ptr(armconnectedvmware.IdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("7b5129bc-8642-4a6a-95f8-63400ca6ec4d"), - // TenantID: to.Ptr("ec46ca82-5d4a-4e3e-b4b7-e27f9318645d"), - // }, - // PublicKey: to.Ptr("8ec7d60c-9700-40b1-8e6e-e5b2f6f477f2"), - // VMID: to.Ptr("f8b82dff-38ef-4220-99ef-d3a3f86ddc6c"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/interfaces.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/interfaces.go new file mode 100644 index 000000000000..470cf00a7a15 --- /dev/null +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/interfaces.go @@ -0,0 +1,28 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package armconnectedvmware + +// InventoryItemPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetInventoryItemProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *ClusterInventoryItem, *DatastoreInventoryItem, *HostInventoryItem, *InventoryItemProperties, *ResourcePoolInventoryItem, +// - *VirtualMachineInventoryItem, *VirtualMachineTemplateInventoryItem, *VirtualNetworkInventoryItem +type InventoryItemPropertiesClassification interface { + // GetInventoryItemProperties returns the InventoryItemProperties content of the underlying type. + GetInventoryItemProperties() *InventoryItemProperties +} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/inventoryitems_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/inventoryitems_client.go index 3de03e5139f2..e6c647f7924f 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/inventoryitems_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/inventoryitems_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware @@ -55,25 +55,28 @@ func NewInventoryItemsClient(subscriptionID string, credential azcore.TokenCrede // Create - Create Or Update InventoryItem. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - vcenterName - Name of the vCenter. // - inventoryItemName - Name of the inventoryItem. // - body - Request payload. // - options - InventoryItemsClientCreateOptions contains the optional parameters for the InventoryItemsClient.Create method. func (client *InventoryItemsClient) Create(ctx context.Context, resourceGroupName string, vcenterName string, inventoryItemName string, body InventoryItem, options *InventoryItemsClientCreateOptions) (InventoryItemsClientCreateResponse, error) { + var err error req, err := client.createCreateRequest(ctx, resourceGroupName, vcenterName, inventoryItemName, body, options) if err != nil { return InventoryItemsClientCreateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return InventoryItemsClientCreateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return InventoryItemsClientCreateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return InventoryItemsClientCreateResponse{}, err } - return client.createHandleResponse(resp) + resp, err := client.createHandleResponse(httpResp) + return resp, err } // createCreateRequest creates the Create request. @@ -100,10 +103,13 @@ func (client *InventoryItemsClient) createCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // createHandleResponse handles the Create response. @@ -118,22 +124,24 @@ func (client *InventoryItemsClient) createHandleResponse(resp *http.Response) (I // Delete - Implements inventoryItem DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - vcenterName - Name of the vCenter. // - inventoryItemName - Name of the inventoryItem. // - options - InventoryItemsClientDeleteOptions contains the optional parameters for the InventoryItemsClient.Delete method. func (client *InventoryItemsClient) Delete(ctx context.Context, resourceGroupName string, vcenterName string, inventoryItemName string, options *InventoryItemsClientDeleteOptions) (InventoryItemsClientDeleteResponse, error) { + var err error req, err := client.deleteCreateRequest(ctx, resourceGroupName, vcenterName, inventoryItemName, options) if err != nil { return InventoryItemsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return InventoryItemsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return InventoryItemsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return InventoryItemsClientDeleteResponse{}, err } return InventoryItemsClientDeleteResponse{}, nil } @@ -162,7 +170,7 @@ func (client *InventoryItemsClient) deleteCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -171,24 +179,27 @@ func (client *InventoryItemsClient) deleteCreateRequest(ctx context.Context, res // Get - Implements InventoryItem GET method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - vcenterName - Name of the vCenter. // - inventoryItemName - Name of the inventoryItem. // - options - InventoryItemsClientGetOptions contains the optional parameters for the InventoryItemsClient.Get method. func (client *InventoryItemsClient) Get(ctx context.Context, resourceGroupName string, vcenterName string, inventoryItemName string, options *InventoryItemsClientGetOptions) (InventoryItemsClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, resourceGroupName, vcenterName, inventoryItemName, options) if err != nil { return InventoryItemsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return InventoryItemsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return InventoryItemsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return InventoryItemsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -215,7 +226,7 @@ func (client *InventoryItemsClient) getCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -232,7 +243,7 @@ func (client *InventoryItemsClient) getHandleResponse(resp *http.Response) (Inve // NewListByVCenterPager - Returns the list of inventoryItems of the given vCenter. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - vcenterName - Name of the vCenter. // - options - InventoryItemsClientListByVCenterOptions contains the optional parameters for the InventoryItemsClient.NewListByVCenterPager @@ -285,7 +296,7 @@ func (client *InventoryItemsClient) listByVCenterCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/inventoryitems_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/inventoryitems_client_example_test.go deleted file mode 100644 index 6048d98a262d..000000000000 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/inventoryitems_client_example_test.go +++ /dev/null @@ -1,140 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armconnectedvmware_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateInventoryItem.json -func ExampleInventoryItemsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewInventoryItemsClient().Create(ctx, "testrg", "ContosoVCenter", "testItem", armconnectedvmware.InventoryItem{ - Properties: &armconnectedvmware.ResourcePoolInventoryItem{ - InventoryType: to.Ptr(armconnectedvmware.InventoryTypeResourcePool), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.InventoryItem = armconnectedvmware.InventoryItem{ - // Name: to.Ptr("testItem"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VCenters/InventoryItems"), - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter/InventoryItems/testItem"), - // Properties: &armconnectedvmware.ResourcePoolInventoryItem{ - // InventoryType: to.Ptr(armconnectedvmware.InventoryTypeResourcePool), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetInventoryItem.json -func ExampleInventoryItemsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewInventoryItemsClient().Get(ctx, "testrg", "ContosoVCenter", "testItem", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.InventoryItem = armconnectedvmware.InventoryItem{ - // Name: to.Ptr("testItem"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VCenters/InventoryItems"), - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter/InventoryItems/testItem"), - // Properties: &armconnectedvmware.ResourcePoolInventoryItem{ - // InventoryType: to.Ptr(armconnectedvmware.InventoryTypeResourcePool), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteInventoryItem.json -func ExampleInventoryItemsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewInventoryItemsClient().Delete(ctx, "testrg", "ContosoVCenter", "testItem", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/InventoryItems_ListByVCenter.json -func ExampleInventoryItemsClient_NewListByVCenterPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewInventoryItemsClient().NewListByVCenterPager("testrg", "ContosoVCenter", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.InventoryItemsList = armconnectedvmware.InventoryItemsList{ - // Value: []*armconnectedvmware.InventoryItem{ - // { - // Name: to.Ptr("testItem"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VCenters/InventoryItems"), - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter/InventoryItems/testItem"), - // Properties: &armconnectedvmware.ResourcePoolInventoryItem{ - // InventoryType: to.Ptr(armconnectedvmware.InventoryTypeResourcePool), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/machineextensions_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/machineextensions_client.go index 649c728d2115..f3b3e85638f5 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/machineextensions_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/machineextensions_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware @@ -55,22 +55,23 @@ func NewMachineExtensionsClient(subscriptionID string, credential azcore.TokenCr // BeginCreateOrUpdate - The operation to create or update the extension. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. -// - name - The name of the machine where the extension should be created or updated. +// - virtualMachineName - 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. // - options - MachineExtensionsClientBeginCreateOrUpdateOptions contains the optional parameters for the MachineExtensionsClient.BeginCreateOrUpdate // method. -func (client *MachineExtensionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters MachineExtension, options *MachineExtensionsClientBeginCreateOrUpdateOptions) (*runtime.Poller[MachineExtensionsClientCreateOrUpdateResponse], error) { +func (client *MachineExtensionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, virtualMachineName string, extensionName string, extensionParameters MachineExtension, options *MachineExtensionsClientBeginCreateOrUpdateOptions) (*runtime.Poller[MachineExtensionsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.createOrUpdate(ctx, resourceGroupName, name, extensionName, extensionParameters, options) + resp, err := client.createOrUpdate(ctx, resourceGroupName, virtualMachineName, extensionName, extensionParameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MachineExtensionsClientCreateOrUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MachineExtensionsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[MachineExtensionsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -79,25 +80,27 @@ func (client *MachineExtensionsClient) BeginCreateOrUpdate(ctx context.Context, // CreateOrUpdate - The operation to create or update the extension. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview -func (client *MachineExtensionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters MachineExtension, options *MachineExtensionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, name, extensionName, extensionParameters, options) +// Generated from API version 2023-03-01-preview +func (client *MachineExtensionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, virtualMachineName string, extensionName string, extensionParameters MachineExtension, options *MachineExtensionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, virtualMachineName, extensionName, extensionParameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *MachineExtensionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters MachineExtension, options *MachineExtensionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}" +func (client *MachineExtensionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, extensionName string, extensionParameters MachineExtension, options *MachineExtensionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/extensions/{extensionName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -106,10 +109,10 @@ func (client *MachineExtensionsClient) createOrUpdateCreateRequest(ctx context.C return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if name == "" { - return nil, errors.New("parameter name cannot be empty") + if virtualMachineName == "" { + return nil, errors.New("parameter virtualMachineName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) if extensionName == "" { return nil, errors.New("parameter extensionName cannot be empty") } @@ -119,28 +122,32 @@ func (client *MachineExtensionsClient) createOrUpdateCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, extensionParameters) + if err := runtime.MarshalAsJSON(req, extensionParameters); err != nil { + return nil, err + } + return req, nil } // BeginDelete - The operation to delete the extension. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. -// - name - The name of the machine where the extension should be deleted. +// - virtualMachineName - The name of the machine where the extension should be deleted. // - extensionName - The name of the machine extension. // - options - MachineExtensionsClientBeginDeleteOptions contains the optional parameters for the MachineExtensionsClient.BeginDelete // method. -func (client *MachineExtensionsClient) BeginDelete(ctx context.Context, resourceGroupName string, name string, extensionName string, options *MachineExtensionsClientBeginDeleteOptions) (*runtime.Poller[MachineExtensionsClientDeleteResponse], error) { +func (client *MachineExtensionsClient) BeginDelete(ctx context.Context, resourceGroupName string, virtualMachineName string, extensionName string, options *MachineExtensionsClientBeginDeleteOptions) (*runtime.Poller[MachineExtensionsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.deleteOperation(ctx, resourceGroupName, name, extensionName, options) + resp, err := client.deleteOperation(ctx, resourceGroupName, virtualMachineName, extensionName, options) if err != nil { return nil, err } - return runtime.NewPoller[MachineExtensionsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[MachineExtensionsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[MachineExtensionsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -149,25 +156,27 @@ func (client *MachineExtensionsClient) BeginDelete(ctx context.Context, resource // Delete - The operation to delete the extension. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview -func (client *MachineExtensionsClient) deleteOperation(ctx context.Context, resourceGroupName string, name string, extensionName string, options *MachineExtensionsClientBeginDeleteOptions) (*http.Response, error) { - req, err := client.deleteCreateRequest(ctx, resourceGroupName, name, extensionName, options) +// Generated from API version 2023-03-01-preview +func (client *MachineExtensionsClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualMachineName string, extensionName string, options *MachineExtensionsClientBeginDeleteOptions) (*http.Response, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceGroupName, virtualMachineName, extensionName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. -func (client *MachineExtensionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, name string, extensionName string, options *MachineExtensionsClientBeginDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}" +func (client *MachineExtensionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, extensionName string, options *MachineExtensionsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/extensions/{extensionName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -176,10 +185,10 @@ func (client *MachineExtensionsClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if name == "" { - return nil, errors.New("parameter name cannot be empty") + if virtualMachineName == "" { + return nil, errors.New("parameter virtualMachineName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) if extensionName == "" { return nil, errors.New("parameter extensionName cannot be empty") } @@ -189,7 +198,7 @@ func (client *MachineExtensionsClient) deleteCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -198,29 +207,32 @@ func (client *MachineExtensionsClient) deleteCreateRequest(ctx context.Context, // Get - The operation to get the extension. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. -// - name - The name of the machine containing the extension. +// - virtualMachineName - The name of the machine containing the extension. // - extensionName - The name of the machine extension. // - options - MachineExtensionsClientGetOptions contains the optional parameters for the MachineExtensionsClient.Get method. -func (client *MachineExtensionsClient) Get(ctx context.Context, resourceGroupName string, name string, extensionName string, options *MachineExtensionsClientGetOptions) (MachineExtensionsClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, resourceGroupName, name, extensionName, options) +func (client *MachineExtensionsClient) Get(ctx context.Context, resourceGroupName string, virtualMachineName string, extensionName string, options *MachineExtensionsClientGetOptions) (MachineExtensionsClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, virtualMachineName, extensionName, options) if err != nil { return MachineExtensionsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return MachineExtensionsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MachineExtensionsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return MachineExtensionsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. -func (client *MachineExtensionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, name string, extensionName string, options *MachineExtensionsClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}" +func (client *MachineExtensionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, extensionName string, options *MachineExtensionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/extensions/{extensionName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -229,10 +241,10 @@ func (client *MachineExtensionsClient) getCreateRequest(ctx context.Context, res return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if name == "" { - return nil, errors.New("parameter name cannot be empty") + if virtualMachineName == "" { + return nil, errors.New("parameter virtualMachineName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) if extensionName == "" { return nil, errors.New("parameter extensionName cannot be empty") } @@ -242,7 +254,7 @@ func (client *MachineExtensionsClient) getCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -259,12 +271,12 @@ func (client *MachineExtensionsClient) getHandleResponse(resp *http.Response) (M // NewListPager - The operation to get all extensions of a non-Azure machine // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. -// - name - The name of the machine containing the extension. +// - virtualMachineName - The name of the machine containing the extension. // - options - MachineExtensionsClientListOptions contains the optional parameters for the MachineExtensionsClient.NewListPager // method. -func (client *MachineExtensionsClient) NewListPager(resourceGroupName string, name string, options *MachineExtensionsClientListOptions) *runtime.Pager[MachineExtensionsClientListResponse] { +func (client *MachineExtensionsClient) NewListPager(resourceGroupName string, virtualMachineName string, options *MachineExtensionsClientListOptions) *runtime.Pager[MachineExtensionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[MachineExtensionsClientListResponse]{ More: func(page MachineExtensionsClientListResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 @@ -273,7 +285,7 @@ func (client *MachineExtensionsClient) NewListPager(resourceGroupName string, na var req *policy.Request var err error if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, name, options) + req, err = client.listCreateRequest(ctx, resourceGroupName, virtualMachineName, options) } else { req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) } @@ -293,8 +305,8 @@ func (client *MachineExtensionsClient) NewListPager(resourceGroupName string, na } // listCreateRequest creates the List request. -func (client *MachineExtensionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, name string, options *MachineExtensionsClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions" +func (client *MachineExtensionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *MachineExtensionsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/extensions" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -303,16 +315,16 @@ func (client *MachineExtensionsClient) listCreateRequest(ctx context.Context, re return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if name == "" { - return nil, errors.New("parameter name cannot be empty") + if virtualMachineName == "" { + return nil, errors.New("parameter virtualMachineName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } @@ -333,20 +345,21 @@ func (client *MachineExtensionsClient) listHandleResponse(resp *http.Response) ( // BeginUpdate - The operation to update the extension. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. -// - name - The name of the machine where the extension should be created or updated. +// - virtualMachineName - 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. // - options - MachineExtensionsClientBeginUpdateOptions contains the optional parameters for the MachineExtensionsClient.BeginUpdate // method. -func (client *MachineExtensionsClient) BeginUpdate(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters MachineExtensionUpdate, options *MachineExtensionsClientBeginUpdateOptions) (*runtime.Poller[MachineExtensionsClientUpdateResponse], error) { +func (client *MachineExtensionsClient) BeginUpdate(ctx context.Context, resourceGroupName string, virtualMachineName string, extensionName string, extensionParameters MachineExtensionUpdate, options *MachineExtensionsClientBeginUpdateOptions) (*runtime.Poller[MachineExtensionsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.update(ctx, resourceGroupName, name, extensionName, extensionParameters, options) + resp, err := client.update(ctx, resourceGroupName, virtualMachineName, extensionName, extensionParameters, options) if err != nil { return nil, err } - return runtime.NewPoller[MachineExtensionsClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[MachineExtensionsClientUpdateResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[MachineExtensionsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -355,25 +368,27 @@ func (client *MachineExtensionsClient) BeginUpdate(ctx context.Context, resource // Update - The operation to update the extension. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview -func (client *MachineExtensionsClient) update(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters MachineExtensionUpdate, options *MachineExtensionsClientBeginUpdateOptions) (*http.Response, error) { - req, err := client.updateCreateRequest(ctx, resourceGroupName, name, extensionName, extensionParameters, options) +// Generated from API version 2023-03-01-preview +func (client *MachineExtensionsClient) update(ctx context.Context, resourceGroupName string, virtualMachineName string, extensionName string, extensionParameters MachineExtensionUpdate, options *MachineExtensionsClientBeginUpdateOptions) (*http.Response, error) { + var err error + req, err := client.updateCreateRequest(ctx, resourceGroupName, virtualMachineName, extensionName, extensionParameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // updateCreateRequest creates the Update request. -func (client *MachineExtensionsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters MachineExtensionUpdate, options *MachineExtensionsClientBeginUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}" +func (client *MachineExtensionsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, extensionName string, extensionParameters MachineExtensionUpdate, options *MachineExtensionsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/extensions/{extensionName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -382,10 +397,10 @@ func (client *MachineExtensionsClient) updateCreateRequest(ctx context.Context, return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if name == "" { - return nil, errors.New("parameter name cannot be empty") + if virtualMachineName == "" { + return nil, errors.New("parameter virtualMachineName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) if extensionName == "" { return nil, errors.New("parameter extensionName cannot be empty") } @@ -395,8 +410,11 @@ func (client *MachineExtensionsClient) updateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, extensionParameters) + if err := runtime.MarshalAsJSON(req, extensionParameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/machineextensions_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/machineextensions_client_example_test.go deleted file mode 100644 index 2acadff22602..000000000000 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/machineextensions_client_example_test.go +++ /dev/null @@ -1,289 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armconnectedvmware_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/PUTExtension.json -func ExampleMachineExtensionsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewMachineExtensionsClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myMachine", "CustomScriptExtension", armconnectedvmware.MachineExtension{ - Location: to.Ptr("eastus2euap"), - Properties: &armconnectedvmware.MachineExtensionProperties{ - Type: to.Ptr("CustomScriptExtension"), - Publisher: to.Ptr("Microsoft.Compute"), - Settings: map[string]any{ - "commandToExecute": "powershell.exe -c \"Get-Process | Where-Object { $_.CPU -gt 10000 }\"", - }, - TypeHandlerVersion: to.Ptr("1.10"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.MachineExtension = armconnectedvmware.MachineExtension{ - // Name: to.Ptr("CustomScriptExtension"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines/extensions"), - // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/Extensions/CustomScriptExtension"), - // Location: to.Ptr("eastus2euap"), - // Properties: &armconnectedvmware.MachineExtensionProperties{ - // Type: to.Ptr("string"), - // AutoUpgradeMinorVersion: to.Ptr(false), - // InstanceView: &armconnectedvmware.MachineExtensionPropertiesInstanceView{ - // Name: to.Ptr("CustomScriptExtension"), - // Type: to.Ptr("CustomScriptExtension"), - // Status: &armconnectedvmware.MachineExtensionInstanceViewStatus{ - // Code: to.Ptr("success"), - // Level: to.Ptr(armconnectedvmware.StatusLevelTypes("Information")), - // Message: to.Ptr("Finished executing command, StdOut: , StdErr:"), - // Time: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-08T20:42:10.999Z"); return t}()), - // }, - // TypeHandlerVersion: to.Ptr("1.10.3"), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // Publisher: to.Ptr("Microsoft.Compute"), - // Settings: "@{commandToExecute=powershell.exe -c \"Get-Process | Where-Object { $_.CPU -gt 10000 }\"}", - // TypeHandlerVersion: to.Ptr("1.10.3"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateExtension.json -func ExampleMachineExtensionsClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewMachineExtensionsClient().BeginUpdate(ctx, "myResourceGroup", "myMachine", "CustomScriptExtension", armconnectedvmware.MachineExtensionUpdate{ - Properties: &armconnectedvmware.MachineExtensionUpdateProperties{ - Type: to.Ptr("CustomScriptExtension"), - Publisher: to.Ptr("Microsoft.Compute"), - Settings: map[string]any{ - "commandToExecute": "powershell.exe -c \"Get-Process | Where-Object { $_.CPU -lt 100 }\"", - }, - TypeHandlerVersion: to.Ptr("1.10"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.MachineExtension = armconnectedvmware.MachineExtension{ - // Name: to.Ptr("CustomScriptExtension"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines/extensions"), - // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/Extensions/CustomScriptExtension"), - // Location: to.Ptr("eastus2euap"), - // Properties: &armconnectedvmware.MachineExtensionProperties{ - // Type: to.Ptr("string"), - // AutoUpgradeMinorVersion: to.Ptr(false), - // InstanceView: &armconnectedvmware.MachineExtensionPropertiesInstanceView{ - // Name: to.Ptr("CustomScriptExtension"), - // Type: to.Ptr("CustomScriptExtension"), - // Status: &armconnectedvmware.MachineExtensionInstanceViewStatus{ - // Code: to.Ptr("success"), - // Level: to.Ptr(armconnectedvmware.StatusLevelTypes("Information")), - // Message: to.Ptr("Finished executing command, StdOut: , StdErr:"), - // Time: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-08T20:42:10.999Z"); return t}()), - // }, - // TypeHandlerVersion: to.Ptr("1.10.3"), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // Publisher: to.Ptr("Microsoft.Compute"), - // Settings: "@{commandToExecute=powershell.exe -c \"Get-Process | Where-Object { $_.CPU -lt 100 }\"}", - // TypeHandlerVersion: to.Ptr("1.10.3"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DELETEExtension.json -func ExampleMachineExtensionsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewMachineExtensionsClient().BeginDelete(ctx, "myResourceGroup", "myMachine", "MMA", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GETExtension.json -func ExampleMachineExtensionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewMachineExtensionsClient().Get(ctx, "myResourceGroup", "myMachine", "CustomScriptExtension", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.MachineExtension = armconnectedvmware.MachineExtension{ - // Name: to.Ptr("CustomScriptExtension"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines/extensions"), - // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/Extensions/CustomScriptExtension"), - // Location: to.Ptr("eastus2euap"), - // Properties: &armconnectedvmware.MachineExtensionProperties{ - // Type: to.Ptr("string"), - // AutoUpgradeMinorVersion: to.Ptr(false), - // InstanceView: &armconnectedvmware.MachineExtensionPropertiesInstanceView{ - // Name: to.Ptr("CustomScriptExtension"), - // Type: to.Ptr("CustomScriptExtension"), - // Status: &armconnectedvmware.MachineExtensionInstanceViewStatus{ - // Code: to.Ptr("success"), - // DisplayStatus: to.Ptr("Provisioning succeeded"), - // Level: to.Ptr(armconnectedvmware.StatusLevelTypes("Information")), - // Message: to.Ptr("Finished executing command, StdOut: , StdErr:"), - // Time: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-08T20:42:10.999Z"); return t}()), - // }, - // TypeHandlerVersion: to.Ptr("1.10.3"), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // Publisher: to.Ptr("Microsoft.Compute"), - // Settings: "@{commandToExecute=powershell.exe -c \"Get-Process | Where-Object { $_.CPU -gt 10000 }\"}", - // TypeHandlerVersion: to.Ptr("1.10.3"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/LISTExtension.json -func ExampleMachineExtensionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewMachineExtensionsClient().NewListPager("myResourceGroup", "myMachine", &armconnectedvmware.MachineExtensionsClientListOptions{Expand: nil}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.MachineExtensionsListResult = armconnectedvmware.MachineExtensionsListResult{ - // Value: []*armconnectedvmware.MachineExtension{ - // { - // Name: to.Ptr("CustomScriptExtension"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines/extensions"), - // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/Extensions/CustomScriptExtension"), - // Location: to.Ptr("eastus2euap"), - // Properties: &armconnectedvmware.MachineExtensionProperties{ - // Type: to.Ptr("CustomScriptExtension"), - // AutoUpgradeMinorVersion: to.Ptr(false), - // InstanceView: &armconnectedvmware.MachineExtensionPropertiesInstanceView{ - // Name: to.Ptr("CustomScriptExtension"), - // Type: to.Ptr("CustomScriptExtension"), - // Status: &armconnectedvmware.MachineExtensionInstanceViewStatus{ - // Code: to.Ptr("success"), - // DisplayStatus: to.Ptr("Provisioning succeeded"), - // Level: to.Ptr(armconnectedvmware.StatusLevelTypes("Information")), - // Message: to.Ptr("formattedMessage: Finished executing command, StdOut: , StdErr: "), - // Time: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-13T17:18:57.405Z"); return t}()), - // }, - // TypeHandlerVersion: to.Ptr("1.10.3"), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // Publisher: to.Ptr("Microsoft.Compute"), - // Settings: map[string]any{ - // "commandToExecute": "powershell.exe -c \"Get-Process | Where-Object { $_.CPU -gt 10000 }\"", - // }, - // TypeHandlerVersion: to.Ptr("1.10.3"), - // }, - // }, - // { - // Name: to.Ptr("winosupdateextension"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines/extensions"), - // ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/Extensions/winosupdateextension"), - // Location: to.Ptr("eastus2euap"), - // Properties: &armconnectedvmware.MachineExtensionProperties{ - // Type: to.Ptr("windowsosupdateextension"), - // AutoUpgradeMinorVersion: to.Ptr(false), - // InstanceView: &armconnectedvmware.MachineExtensionPropertiesInstanceView{ - // Name: to.Ptr("winosupdateextension"), - // Type: to.Ptr("windowsosupdateextension"), - // Status: &armconnectedvmware.MachineExtensionInstanceViewStatus{ - // }, - // TypeHandlerVersion: to.Ptr("1.0.0.0"), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // Publisher: to.Ptr("microsoft.softwareupdatemanagement.test"), - // Settings: map[string]any{ - // }, - // TypeHandlerVersion: to.Ptr("1.0.0.0"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/models.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/models.go index cf37092a3cbf..acd64c6ad50a 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/models.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/models.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware @@ -95,8 +95,8 @@ type ClusterInventoryItem struct { // Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. MoRefID *string - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState } // GetInventoryItemProperties implements the InventoryItemPropertiesClassification interface for type ClusterInventoryItem. @@ -104,13 +104,13 @@ func (c *ClusterInventoryItem) GetInventoryItemProperties() *InventoryItemProper return &InventoryItemProperties{ InventoryType: c.InventoryType, ManagedResourceID: c.ManagedResourceID, - MoRefID: c.MoRefID, MoName: c.MoName, + MoRefID: c.MoRefID, ProvisioningState: c.ProvisioningState, } } -// ClusterProperties - Defines the resource properties. +// ClusterProperties - Describes the properties of a Cluster. type ClusterProperties struct { // Gets or sets the inventory Item ID for the cluster. InventoryItemID *string @@ -124,58 +124,35 @@ type ClusterProperties struct { // READ-ONLY; Gets the name of the corresponding resource in Kubernetes. CustomResourceName *string - // READ-ONLY; Gets or sets the datastore ARM ids. + // READ-ONLY; Gets the datastore ARM ids. DatastoreIDs []*string // READ-ONLY; Gets or sets the vCenter Managed Object name for the cluster. MoName *string - // READ-ONLY; Gets or sets the network ARM ids. + // READ-ONLY; Gets the network ARM ids. NetworkIDs []*string - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState // READ-ONLY; The resource status information. Statuses []*ResourceStatus - // READ-ONLY; Gets or sets a unique identifier for this resource. - UUID *string -} - -// ClustersClientBeginCreateOptions contains the optional parameters for the ClustersClient.BeginCreate method. -type ClustersClientBeginCreateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// ClustersClientBeginDeleteOptions contains the optional parameters for the ClustersClient.BeginDelete method. -type ClustersClientBeginDeleteOptions struct { - // Whether force delete was specified. - Force *bool - // Resumes the LRO from the provided token. - ResumeToken string -} + // READ-ONLY; Gets the max CPU usage across all cores on the cluster in MHz. + TotalCPUMHz *int64 -// ClustersClientGetOptions contains the optional parameters for the ClustersClient.Get method. -type ClustersClientGetOptions struct { - // placeholder for future optional parameters -} + // READ-ONLY; Gets the total amount of physical memory on the cluster in GB. + TotalMemoryGB *int64 -// ClustersClientListByResourceGroupOptions contains the optional parameters for the ClustersClient.NewListByResourceGroupPager -// method. -type ClustersClientListByResourceGroupOptions struct { - // placeholder for future optional parameters -} + // READ-ONLY; Gets or sets a unique identifier for this resource. + UUID *string -// ClustersClientListOptions contains the optional parameters for the ClustersClient.NewListPager method. -type ClustersClientListOptions struct { - // placeholder for future optional parameters -} + // READ-ONLY; Gets the used CPU usage across all cores on the cluster in MHz. + UsedCPUMHz *int64 -// ClustersClientUpdateOptions contains the optional parameters for the ClustersClient.Update method. -type ClustersClientUpdateOptions struct { - // placeholder for future optional parameters + // READ-ONLY; Gets the used physical memory on the cluster in GB. + UsedMemoryGB *int64 } // ClustersList - List of Clusters. @@ -239,8 +216,8 @@ type DatastoreInventoryItem struct { // Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. MoRefID *string - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState } // GetInventoryItemProperties implements the InventoryItemPropertiesClassification interface for type DatastoreInventoryItem. @@ -248,13 +225,13 @@ func (d *DatastoreInventoryItem) GetInventoryItemProperties() *InventoryItemProp return &InventoryItemProperties{ InventoryType: d.InventoryType, ManagedResourceID: d.ManagedResourceID, - MoRefID: d.MoRefID, MoName: d.MoName, + MoRefID: d.MoRefID, ProvisioningState: d.ProvisioningState, } } -// DatastoreProperties - Defines the resource properties. +// DatastoreProperties - Describes the properties of a Datastore. type DatastoreProperties struct { // Gets or sets the inventory Item ID for the datastore. InventoryItemID *string @@ -265,9 +242,15 @@ type DatastoreProperties struct { // Gets or sets the ARM Id of the vCenter resource in which this datastore resides. VCenterID *string + // READ-ONLY; Gets or sets Maximum capacity of this datastore in GBs. + CapacityGB *int64 + // READ-ONLY; Gets the name of the corresponding resource in Kubernetes. CustomResourceName *string + // READ-ONLY; Gets or sets Available space of this datastore in GBs. + FreeSpaceGB *int64 + // READ-ONLY; Gets or sets the vCenter Managed Object name for the datastore. MoName *string @@ -281,41 +264,6 @@ type DatastoreProperties struct { UUID *string } -// DatastoresClientBeginCreateOptions contains the optional parameters for the DatastoresClient.BeginCreate method. -type DatastoresClientBeginCreateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DatastoresClientBeginDeleteOptions contains the optional parameters for the DatastoresClient.BeginDelete method. -type DatastoresClientBeginDeleteOptions struct { - // Whether force delete was specified. - Force *bool - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DatastoresClientGetOptions contains the optional parameters for the DatastoresClient.Get method. -type DatastoresClientGetOptions struct { - // placeholder for future optional parameters -} - -// DatastoresClientListByResourceGroupOptions contains the optional parameters for the DatastoresClient.NewListByResourceGroupPager -// method. -type DatastoresClientListByResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// DatastoresClientListOptions contains the optional parameters for the DatastoresClient.NewListPager method. -type DatastoresClientListOptions struct { - // placeholder for future optional parameters -} - -// DatastoresClientUpdateOptions contains the optional parameters for the DatastoresClient.Update method. -type DatastoresClientUpdateOptions struct { - // placeholder for future optional parameters -} - // DatastoresList - List of Datastores. type DatastoresList struct { // REQUIRED; Array of Datastores @@ -325,18 +273,30 @@ type DatastoresList struct { NextLink *string } -// ErrorDetail - Error details. +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info any + + // READ-ONLY; The additional info type. + Type *string +} + +// ErrorDetail - The error detail. type ErrorDetail struct { - // REQUIRED; The error's code. - Code *string + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo - // REQUIRED; A human readable error message. - Message *string + // READ-ONLY; The error code. + Code *string - // Additional error details. + // READ-ONLY; The error details. Details []*ErrorDetail - // Indicates which property in the request is responsible for the error. + // READ-ONLY; The error message. + Message *string + + // READ-ONLY; The error target. Target *string } @@ -349,18 +309,24 @@ type ExtendedLocation struct { Type *string } +// ExtensionTargetProperties - Describes the Machine Extension Target Version Properties +type ExtensionTargetProperties struct { + // Properties for the specified Extension to Upgrade. + TargetVersion *string +} + // GuestAgent - Defines the GuestAgent. type GuestAgent struct { // REQUIRED; Resource properties. Properties *GuestAgentProperties - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The system data. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" @@ -376,8 +342,11 @@ type GuestAgentList struct { NextLink *string } -// GuestAgentProfile - Defines the resource properties. +// GuestAgentProfile - Specifies the guest agent settings for the virtual machine. type GuestAgentProfile struct { + // Gets or sets the Public Key provided by the client for enabling guest management. + ClientPublicKey *string + // READ-ONLY; The hybrid machine agent full version. AgentVersion *string @@ -387,6 +356,9 @@ type GuestAgentProfile struct { // READ-ONLY; The time of the last status change. LastStatusChange *time.Time + // READ-ONLY; Specifies whether any MS SQL instance is discovered on the machine. + MssqlDiscovered *string + // READ-ONLY; The status of the hybrid machine agent. Status *StatusTypes @@ -394,7 +366,13 @@ type GuestAgentProfile struct { VMUUID *string } -// GuestAgentProperties - Defines the resource properties. +// GuestAgentProfileUpdate - Specifies the guest agent settings for the virtual machine. +type GuestAgentProfileUpdate struct { + // Gets or sets the Public Key provided by the client for enabling guest management. + ClientPublicKey *string +} + +// GuestAgentProperties - Describes the properties of a Virtual Machine Guest Agent. type GuestAgentProperties struct { // Username / Password Credentials to provision guest agent. Credentials *GuestCredential @@ -402,14 +380,17 @@ type GuestAgentProperties struct { // HTTP Proxy configuration for the VM. HTTPProxyConfig *HTTPProxyConfiguration + // The resource id of the private link scope this machine is assigned to, if any. + PrivateLinkScopeResourceID *string + // Gets or sets the guest agent provisioning action. ProvisioningAction *ProvisioningAction // READ-ONLY; Gets the name of the corresponding resource in Kubernetes. CustomResourceName *string - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState // READ-ONLY; Gets or sets the guest agent status. Status *string @@ -421,28 +402,6 @@ type GuestAgentProperties struct { UUID *string } -// GuestAgentsClientBeginCreateOptions contains the optional parameters for the GuestAgentsClient.BeginCreate method. -type GuestAgentsClientBeginCreateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// GuestAgentsClientBeginDeleteOptions contains the optional parameters for the GuestAgentsClient.BeginDelete method. -type GuestAgentsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// GuestAgentsClientGetOptions contains the optional parameters for the GuestAgentsClient.Get method. -type GuestAgentsClientGetOptions struct { - // placeholder for future optional parameters -} - -// GuestAgentsClientListByVMOptions contains the optional parameters for the GuestAgentsClient.NewListByVMPager method. -type GuestAgentsClientListByVMOptions struct { - // placeholder for future optional parameters -} - // GuestCredential - Username / Password Credentials to connect to guest. type GuestCredential struct { // Gets or sets the password to connect with the guest. @@ -458,7 +417,7 @@ type HTTPProxyConfiguration struct { HTTPSProxy *string } -// HardwareProfile - Defines the resource properties. +// HardwareProfile - Specifies the hardware settings for the virtual machine. type HardwareProfile struct { // Gets or sets memory size in MBs for the vm. MemorySizeMB *int32 @@ -528,8 +487,8 @@ type HostInventoryItem struct { // Parent host inventory resource details. Parent *InventoryItemDetails - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState } // GetInventoryItemProperties implements the InventoryItemPropertiesClassification interface for type HostInventoryItem. @@ -537,13 +496,13 @@ func (h *HostInventoryItem) GetInventoryItemProperties() *InventoryItemPropertie return &InventoryItemProperties{ InventoryType: h.InventoryType, ManagedResourceID: h.ManagedResourceID, - MoRefID: h.MoRefID, MoName: h.MoName, + MoRefID: h.MoRefID, ProvisioningState: h.ProvisioningState, } } -// HostProperties - Defines the resource properties. +// HostProperties - Describes the properties of a Host. type HostProperties struct { // Gets or sets the inventory Item ID for the host. InventoryItemID *string @@ -554,14 +513,32 @@ type HostProperties struct { // Gets or sets the ARM Id of the vCenter resource in which this host resides. VCenterID *string + // READ-ONLY; Gets the max CPU usage across all cores in MHz. + CPUMhz *int64 + // READ-ONLY; Gets the name of the corresponding resource in Kubernetes. CustomResourceName *string + // READ-ONLY; Gets the datastore ARM ids. + DatastoreIDs []*string + + // READ-ONLY; Gets the total amount of physical memory on the host in GB. + MemorySizeGB *int64 + // READ-ONLY; Gets or sets the vCenter Managed Object name for the host. MoName *string - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Gets the network ARM ids. + NetworkIDs []*string + + // READ-ONLY; Gets the used CPU usage across all cores in MHz. + OverallCPUUsageMHz *int64 + + // READ-ONLY; Gets the used physical memory on the host in GB. + OverallMemoryUsageGB *int64 + + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState // READ-ONLY; The resource status information. Statuses []*ResourceStatus @@ -570,41 +547,6 @@ type HostProperties struct { UUID *string } -// HostsClientBeginCreateOptions contains the optional parameters for the HostsClient.BeginCreate method. -type HostsClientBeginCreateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// HostsClientBeginDeleteOptions contains the optional parameters for the HostsClient.BeginDelete method. -type HostsClientBeginDeleteOptions struct { - // Whether force delete was specified. - Force *bool - // Resumes the LRO from the provided token. - ResumeToken string -} - -// HostsClientGetOptions contains the optional parameters for the HostsClient.Get method. -type HostsClientGetOptions struct { - // placeholder for future optional parameters -} - -// HostsClientListByResourceGroupOptions contains the optional parameters for the HostsClient.NewListByResourceGroupPager -// method. -type HostsClientListByResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// HostsClientListOptions contains the optional parameters for the HostsClient.NewListPager method. -type HostsClientListOptions struct { - // placeholder for future optional parameters -} - -// HostsClientUpdateOptions contains the optional parameters for the HostsClient.Update method. -type HostsClientUpdateOptions struct { - // placeholder for future optional parameters -} - // HostsList - List of Hosts. type HostsList struct { // REQUIRED; Array of Hosts @@ -619,42 +561,19 @@ type HybridIdentityMetadata struct { // REQUIRED; Resource properties. Properties *HybridIdentityMetadataProperties - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The system data. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// HybridIdentityMetadataClientCreateOptions contains the optional parameters for the HybridIdentityMetadataClient.Create -// method. -type HybridIdentityMetadataClientCreateOptions struct { - // placeholder for future optional parameters -} - -// HybridIdentityMetadataClientDeleteOptions contains the optional parameters for the HybridIdentityMetadataClient.Delete -// method. -type HybridIdentityMetadataClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// HybridIdentityMetadataClientGetOptions contains the optional parameters for the HybridIdentityMetadataClient.Get method. -type HybridIdentityMetadataClientGetOptions struct { - // placeholder for future optional parameters -} - -// HybridIdentityMetadataClientListByVMOptions contains the optional parameters for the HybridIdentityMetadataClient.NewListByVMPager -// method. -type HybridIdentityMetadataClientListByVMOptions struct { - // placeholder for future optional parameters -} - // HybridIdentityMetadataList - List of HybridIdentityMetadata. type HybridIdentityMetadataList struct { // REQUIRED; Array of HybridIdentityMetadata @@ -664,7 +583,7 @@ type HybridIdentityMetadataList struct { NextLink *string } -// HybridIdentityMetadataProperties - Defines the resource properties. +// HybridIdentityMetadataProperties - Describes the properties of Hybrid Identity Metadata for a Virtual Machine. type HybridIdentityMetadataProperties struct { // Gets or sets the Public Key. PublicKey *string @@ -675,8 +594,8 @@ type HybridIdentityMetadataProperties struct { // READ-ONLY; The identity of the resource. Identity *Identity - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState } // Identity - Managed service identity. @@ -691,6 +610,39 @@ type Identity struct { TenantID *string } +// InfrastructureProfile - Specifies the vCenter infrastructure specific settings for the virtual machine. +type InfrastructureProfile struct { + // Firmware type + FirmwareType *FirmwareType + + // Gets or sets the inventory Item ID for the virtual machine. + InventoryItemID *string + + // Gets or sets the SMBIOS UUID of the vm. + SmbiosUUID *string + + // Gets or sets the ARM Id of the template resource to deploy the virtual machine. + TemplateID *string + + // Gets or sets the ARM Id of the vCenter resource in which this resource pool resides. + VCenterID *string + + // READ-ONLY; Gets the name of the corresponding resource in Kubernetes. + CustomResourceName *string + + // READ-ONLY; Gets or sets the folder path of the vm. + FolderPath *string + + // READ-ONLY; Gets or sets the instance uuid of the vm. + InstanceUUID *string + + // READ-ONLY; Gets or sets the vCenter Managed Object name for the virtual machine. + MoName *string + + // READ-ONLY; Gets or sets the vCenter MoRef (Managed Object Reference) ID for the virtual machine. + MoRefID *string +} + // InventoryItem - Defines the inventory item. type InventoryItem struct { // REQUIRED; Resource properties. @@ -701,39 +653,32 @@ type InventoryItem struct { // validate and persist this value. Kind *string - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The system data. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// InventoryItemDetails - Defines the resource properties. +// InventoryItemDetails - Describes the properties of an Inventory Item reference. type InventoryItemDetails struct { // Gets or sets the inventory Item ID for the resource. InventoryItemID *string + // The inventory type. + InventoryType *InventoryType + // Gets or sets the vCenter Managed Object name for the resource. MoName *string } -// InventoryItemPropertiesClassification provides polymorphic access to related types. -// Call the interface's GetInventoryItemProperties() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *ClusterInventoryItem, *DatastoreInventoryItem, *HostInventoryItem, *InventoryItemProperties, *ResourcePoolInventoryItem, -// - *VirtualMachineInventoryItem, *VirtualMachineTemplateInventoryItem, *VirtualNetworkInventoryItem -type InventoryItemPropertiesClassification interface { - // GetInventoryItemProperties returns the InventoryItemProperties content of the underlying type. - GetInventoryItemProperties() *InventoryItemProperties -} - -// InventoryItemProperties - Defines the resource properties. +// InventoryItemProperties - Describes the properties of an Inventory Item. type InventoryItemProperties struct { // REQUIRED; They inventory type. InventoryType *InventoryType @@ -747,34 +692,13 @@ type InventoryItemProperties struct { // Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. MoRefID *string - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState } // GetInventoryItemProperties implements the InventoryItemPropertiesClassification interface for type InventoryItemProperties. func (i *InventoryItemProperties) GetInventoryItemProperties() *InventoryItemProperties { return i } -// InventoryItemsClientCreateOptions contains the optional parameters for the InventoryItemsClient.Create method. -type InventoryItemsClientCreateOptions struct { - // placeholder for future optional parameters -} - -// InventoryItemsClientDeleteOptions contains the optional parameters for the InventoryItemsClient.Delete method. -type InventoryItemsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// InventoryItemsClientGetOptions contains the optional parameters for the InventoryItemsClient.Get method. -type InventoryItemsClientGetOptions struct { - // placeholder for future optional parameters -} - -// InventoryItemsClientListByVCenterOptions contains the optional parameters for the InventoryItemsClient.NewListByVCenterPager -// method. -type InventoryItemsClientListByVCenterOptions struct { - // placeholder for future optional parameters -} - // InventoryItemsList - List of InventoryItems. type InventoryItemsList struct { // REQUIRED; Array of InventoryItems @@ -926,36 +850,10 @@ type MachineExtensionUpdateProperties struct { TypeHandlerVersion *string } -// MachineExtensionsClientBeginCreateOrUpdateOptions contains the optional parameters for the MachineExtensionsClient.BeginCreateOrUpdate -// method. -type MachineExtensionsClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// MachineExtensionsClientBeginDeleteOptions contains the optional parameters for the MachineExtensionsClient.BeginDelete -// method. -type MachineExtensionsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// MachineExtensionsClientBeginUpdateOptions contains the optional parameters for the MachineExtensionsClient.BeginUpdate -// method. -type MachineExtensionsClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// MachineExtensionsClientGetOptions contains the optional parameters for the MachineExtensionsClient.Get method. -type MachineExtensionsClientGetOptions struct { - // placeholder for future optional parameters -} - -// MachineExtensionsClientListOptions contains the optional parameters for the MachineExtensionsClient.NewListPager method. -type MachineExtensionsClientListOptions struct { - // The expand expression to apply on the operation. - Expand *string +// MachineExtensionUpgrade - Describes the Machine Extension Upgrade Properties +type MachineExtensionUpgrade struct { + // Describes the Extension Target Properties. + ExtensionTargets map[string]*ExtensionTargetProperties } // MachineExtensionsListResult - Describes the Machine Extensions List Result. @@ -1022,13 +920,13 @@ type NetworkInterfaceUpdate struct { PowerOnBoot *PowerOnBootOption } -// NetworkProfile - Defines the resource properties. +// NetworkProfile - Specifies the network interfaces of the virtual machine. type NetworkProfile struct { // Gets or sets the list of network interfaces associated with the virtual machine. NetworkInterfaces []*NetworkInterface } -// NetworkProfileUpdate - Defines the update resource properties. +// NetworkProfileUpdate - Specifies the network interfaces of the virtual machine. type NetworkProfileUpdate struct { // Gets or sets the list of network interfaces associated with the virtual machine. NetworkInterfaces []*NetworkInterfaceUpdate @@ -1101,11 +999,6 @@ type OperationDisplay struct { Resource *string } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. -type OperationsClientListOptions struct { - // placeholder for future optional parameters -} - // OperationsList - Lists the operations available. type OperationsList struct { // REQUIRED; Array of operations @@ -1115,7 +1008,7 @@ type OperationsList struct { NextLink *string } -// OsProfile - Defines the resource properties. +// OsProfile - Specifies the operating system settings for the virtual machine. type OsProfile struct { // Gets or sets administrator password. AdminPassword *string @@ -1154,13 +1047,43 @@ type OsProfile struct { ToolsVersionStatus *string } +// OsProfileForVMInstance - Specifies the operating system settings for the virtual machine. +type OsProfileForVMInstance struct { + // Sets administrator password. + AdminPassword *string + + // Gets or sets administrator username. + AdminUsername *string + + // Gets or sets computer name. + ComputerName *string + + // Gets or sets the guestId. + GuestID *string + + // Gets or sets the type of the os. + OSType *OsType + + // READ-ONLY; Gets or sets os sku. + OSSKU *string + + // READ-ONLY; Gets or sets the current running status of VMware Tools running in the guest operating system. + ToolsRunningStatus *string + + // READ-ONLY; Gets or sets the current version of VMware Tools. + ToolsVersion *string + + // READ-ONLY; Gets or sets the current version status of VMware Tools installed in the guest operating system. + ToolsVersionStatus *string +} + // OsProfileLinuxConfiguration - Specifies the linux configuration for update management. type OsProfileLinuxConfiguration struct { // Specifies the patch settings. PatchSettings *PatchSettings } -// OsProfileUpdate - Defines the os update properties. +// OsProfileUpdate - Specifies the operating system settings for the virtual machine. type OsProfileUpdate struct { // Specifies the linux configuration for update management. LinuxConfiguration *OsProfileUpdateLinuxConfiguration @@ -1196,7 +1119,7 @@ type PatchSettings struct { PatchMode *string } -// PlacementProfile - Defines the resource properties. +// PlacementProfile - Specifies the compute and storage placement settings for the virtual machine. type PlacementProfile struct { // Gets or sets the ARM Id of the cluster resource on which this virtual machine will deploy. ClusterID *string @@ -1266,8 +1189,8 @@ type ResourcePoolInventoryItem struct { // Parent resourcePool inventory resource details. Parent *InventoryItemDetails - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState } // GetInventoryItemProperties implements the InventoryItemPropertiesClassification interface for type ResourcePoolInventoryItem. @@ -1275,13 +1198,13 @@ func (r *ResourcePoolInventoryItem) GetInventoryItemProperties() *InventoryItemP return &InventoryItemProperties{ InventoryType: r.InventoryType, ManagedResourceID: r.ManagedResourceID, - MoRefID: r.MoRefID, MoName: r.MoName, + MoRefID: r.MoRefID, ProvisioningState: r.ProvisioningState, } } -// ResourcePoolProperties - Defines the resource properties. +// ResourcePoolProperties - Describes the properties of a Resource Pool. type ResourcePoolProperties struct { // Gets or sets the inventory Item ID for the resource pool. InventoryItemID *string @@ -1292,10 +1215,16 @@ type ResourcePoolProperties struct { // Gets or sets the ARM Id of the vCenter resource in which this resource pool resides. VCenterID *string + // READ-ONLY; Gets the max CPU usage across all cores on the pool in MHz. + CPUCapacityMHz *int64 + // READ-ONLY; Gets or sets CPULimitMHz which specifies a CPU usage limit in MHz. Utilization will not exceed this limit even // if there are available resources. CPULimitMHz *int64 + // READ-ONLY; Gets the used CPU usage across all cores on the pool in MHz. + CPUOverallUsageMHz *int64 + // READ-ONLY; Gets or sets CPUReservationMHz which specifies the CPU size in MHz that is guaranteed to be available. CPUReservationMHz *int64 @@ -1306,10 +1235,19 @@ type ResourcePoolProperties struct { // READ-ONLY; Gets the name of the corresponding resource in Kubernetes. CustomResourceName *string + // READ-ONLY; Gets the datastore ARM ids. + DatastoreIDs []*string + + // READ-ONLY; Gets the total amount of physical memory on the pool in GB. + MemCapacityGB *int64 + // READ-ONLY; Gets or sets MemLimitMB specifies a memory usage limit in megabytes. Utilization will not exceed the specified // limit even if there are available resources. MemLimitMB *int64 + // READ-ONLY; Gets the used physical memory on the pool in GB. + MemOverallUsageGB *int64 + // READ-ONLY; Gets or sets MemReservationMB which specifies the guaranteed available memory in megabytes. MemReservationMB *int64 @@ -1320,8 +1258,11 @@ type ResourcePoolProperties struct { // READ-ONLY; Gets or sets the vCenter Managed Object name for the resource pool. MoName *string - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Gets the network ARM ids. + NetworkIDs []*string + + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState // READ-ONLY; The resource status information. Statuses []*ResourceStatus @@ -1330,41 +1271,6 @@ type ResourcePoolProperties struct { UUID *string } -// ResourcePoolsClientBeginCreateOptions contains the optional parameters for the ResourcePoolsClient.BeginCreate method. -type ResourcePoolsClientBeginCreateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// ResourcePoolsClientBeginDeleteOptions contains the optional parameters for the ResourcePoolsClient.BeginDelete method. -type ResourcePoolsClientBeginDeleteOptions struct { - // Whether force delete was specified. - Force *bool - // Resumes the LRO from the provided token. - ResumeToken string -} - -// ResourcePoolsClientGetOptions contains the optional parameters for the ResourcePoolsClient.Get method. -type ResourcePoolsClientGetOptions struct { - // placeholder for future optional parameters -} - -// ResourcePoolsClientListByResourceGroupOptions contains the optional parameters for the ResourcePoolsClient.NewListByResourceGroupPager -// method. -type ResourcePoolsClientListByResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// ResourcePoolsClientListOptions contains the optional parameters for the ResourcePoolsClient.NewListPager method. -type ResourcePoolsClientListOptions struct { - // placeholder for future optional parameters -} - -// ResourcePoolsClientUpdateOptions contains the optional parameters for the ResourcePoolsClient.Update method. -type ResourcePoolsClientUpdateOptions struct { - // placeholder for future optional parameters -} - // ResourcePoolsList - List of ResourcePools. type ResourcePoolsList struct { // REQUIRED; Array of ResourcePools @@ -1408,7 +1314,7 @@ type StopVirtualMachineOptions struct { SkipShutdown *bool } -// StorageProfile - Defines the resource properties. +// StorageProfile - Specifies the storage settings for the virtual machine disks. type StorageProfile struct { // Gets or sets the list of virtual disks associated with the virtual machine. Disks []*VirtualDisk @@ -1417,7 +1323,7 @@ type StorageProfile struct { ScsiControllers []*VirtualSCSIController } -// StorageProfileUpdate - Defines the resource update properties. +// StorageProfileUpdate - Specifies the storage settings for the virtual machine disks. type StorageProfileUpdate struct { // Gets or sets the list of virtual disks associated with the virtual machine. Disks []*VirtualDiskUpdate @@ -1482,7 +1388,7 @@ type VCenter struct { Type *string } -// VCenterProperties - Defines the resource properties. +// VCenterProperties - Describes the properties of a VCenter. type VCenterProperties struct { // REQUIRED; Gets or sets the FQDN/IPAddress of the vCenter. Fqdn *string @@ -1502,8 +1408,8 @@ type VCenterProperties struct { // READ-ONLY; Gets or sets the instance UUID of the vCenter. InstanceUUID *string - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState // READ-ONLY; The resource status information. Statuses []*ResourceStatus @@ -1515,41 +1421,6 @@ type VCenterProperties struct { Version *string } -// VCentersClientBeginCreateOptions contains the optional parameters for the VCentersClient.BeginCreate method. -type VCentersClientBeginCreateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VCentersClientBeginDeleteOptions contains the optional parameters for the VCentersClient.BeginDelete method. -type VCentersClientBeginDeleteOptions struct { - // Whether force delete was specified. - Force *bool - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VCentersClientGetOptions contains the optional parameters for the VCentersClient.Get method. -type VCentersClientGetOptions struct { - // placeholder for future optional parameters -} - -// VCentersClientListByResourceGroupOptions contains the optional parameters for the VCentersClient.NewListByResourceGroupPager -// method. -type VCentersClientListByResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// VCentersClientListOptions contains the optional parameters for the VCentersClient.NewListPager method. -type VCentersClientListOptions struct { - // placeholder for future optional parameters -} - -// VCentersClientUpdateOptions contains the optional parameters for the VCentersClient.Update method. -type VCentersClientUpdateOptions struct { - // placeholder for future optional parameters -} - // VCentersList - List of VCenters. type VCentersList struct { // REQUIRED; Array of VCenters @@ -1568,6 +1439,45 @@ type VICredential struct { Username *string } +// VMInstanceHybridIdentityMetadata - Defines the HybridIdentityMetadata. +type VMInstanceHybridIdentityMetadata struct { + // REQUIRED; Resource properties. + Properties *VMInstanceHybridIdentityMetadataProperties + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// VMInstanceHybridIdentityMetadataList - List of HybridIdentityMetadata. +type VMInstanceHybridIdentityMetadataList struct { + // REQUIRED; Array of HybridIdentityMetadata + Value []*VMInstanceHybridIdentityMetadata + + // Url to follow for getting next page of HybridIdentityMetadata. + NextLink *string +} + +// VMInstanceHybridIdentityMetadataProperties - Describes the properties of Hybrid Identity Metadata for a Virtual Machine. +type VMInstanceHybridIdentityMetadataProperties struct { + // Gets or sets the Public Key. + PublicKey *string + + // The unique identifier for the resource. + ResourceUID *string + + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState +} + // VirtualDisk - Virtual disk model type VirtualDisk struct { // Gets or sets the controller id. @@ -1765,11 +1675,98 @@ type VirtualMachineInstallPatchesResult struct { Status *PatchOperationStatus } +// VirtualMachineInstance - Define the virtualMachineInstance. +type VirtualMachineInstance struct { + // REQUIRED; Resource properties. + Properties *VirtualMachineInstanceProperties + + // Gets or sets the extended location. + ExtendedLocation *ExtendedLocation + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// VirtualMachineInstanceProperties - Describes the properties of a Virtual Machine Instance. +type VirtualMachineInstanceProperties struct { + // Hardware properties. + HardwareProfile *HardwareProfile + + // Gets the infrastructure profile. + InfrastructureProfile *InfrastructureProfile + + // Network properties. + NetworkProfile *NetworkProfile + + // OS properties. + OSProfile *OsProfileForVMInstance + + // Placement properties. + PlacementProfile *PlacementProfile + + // Gets the security profile. + SecurityProfile *SecurityProfile + + // Storage properties. + StorageProfile *StorageProfile + + // READ-ONLY; Gets the power state of the virtual machine. + PowerState *string + + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState + + // READ-ONLY; Gets or sets a unique identifier for the vm resource. + ResourceUID *string + + // READ-ONLY; The resource status information. + Statuses []*ResourceStatus +} + +// VirtualMachineInstanceUpdate - Defines the virtualMachineInstanceUpdate. +type VirtualMachineInstanceUpdate struct { + // Resource properties. + Properties *VirtualMachineInstanceUpdateProperties +} + +// VirtualMachineInstanceUpdateProperties - Describes the properties of a Virtual Machine. +type VirtualMachineInstanceUpdateProperties struct { + // Specifies the hardware settings for the virtual machine. + HardwareProfile *HardwareProfile + + // Specifies the network interfaces of the virtual machine. + NetworkProfile *NetworkProfileUpdate + + // Specifies the storage settings for the virtual machine disks. + StorageProfile *StorageProfileUpdate +} + +// VirtualMachineInstancesList - List of VirtualMachineInstances. +type VirtualMachineInstancesList struct { + // REQUIRED; Array of VirtualMachines + Value []*VirtualMachineInstance + + // Url to follow for getting next page of VirtualMachines. + NextLink *string +} + // VirtualMachineInventoryItem - The VM inventory item. type VirtualMachineInventoryItem struct { // REQUIRED; They inventory type. InventoryType *InventoryType + // Cluster inventory resource details. + Cluster *InventoryItemDetails + // Gets or sets the folder path of the vm. FolderPath *string @@ -1806,8 +1803,8 @@ type VirtualMachineInventoryItem struct { // READ-ONLY; Gets the power state of the virtual machine. PowerState *string - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState // READ-ONLY; Gets or sets the current running status of VMware Tools running in the guest operating system. ToolsRunningStatus *string @@ -1824,13 +1821,13 @@ func (v *VirtualMachineInventoryItem) GetInventoryItemProperties() *InventoryIte return &InventoryItemProperties{ InventoryType: v.InventoryType, ManagedResourceID: v.ManagedResourceID, - MoRefID: v.MoRefID, MoName: v.MoName, + MoRefID: v.MoRefID, ProvisioningState: v.ProvisioningState, } } -// VirtualMachineProperties - Defines the resource properties. +// VirtualMachineProperties - Describes the properties of a Virtual Machine. type VirtualMachineProperties struct { // Firmware type FirmwareType *FirmwareType @@ -1889,8 +1886,8 @@ type VirtualMachineProperties struct { // READ-ONLY; Gets the power state of the virtual machine. PowerState *string - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState // READ-ONLY; The resource status information. Statuses []*ResourceStatus @@ -1966,8 +1963,14 @@ type VirtualMachineTemplateInventoryItem struct { // Gets or sets the type of the os. OSType *OsType - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState + + // READ-ONLY; Gets or sets the current version of VMware Tools. + ToolsVersion *string + + // READ-ONLY; Gets or sets the current version status of VMware Tools installed in the guest operating system. + ToolsVersionStatus *string } // GetInventoryItemProperties implements the InventoryItemPropertiesClassification interface for type VirtualMachineTemplateInventoryItem. @@ -1975,13 +1978,13 @@ func (v *VirtualMachineTemplateInventoryItem) GetInventoryItemProperties() *Inve return &InventoryItemProperties{ InventoryType: v.InventoryType, ManagedResourceID: v.ManagedResourceID, - MoRefID: v.MoRefID, MoName: v.MoName, + MoRefID: v.MoRefID, ProvisioningState: v.ProvisioningState, } } -// VirtualMachineTemplateProperties - Defines the resource properties. +// VirtualMachineTemplateProperties - Describes the properties of a Virtual Machine Template. type VirtualMachineTemplateProperties struct { // Gets or sets the inventory Item ID for the virtual machine template. InventoryItemID *string @@ -2025,8 +2028,8 @@ type VirtualMachineTemplateProperties struct { // READ-ONLY; Gets or sets the type of the os. OSType *OsType - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState // READ-ONLY; The resource status information. Statuses []*ResourceStatus @@ -2041,45 +2044,6 @@ type VirtualMachineTemplateProperties struct { UUID *string } -// VirtualMachineTemplatesClientBeginCreateOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginCreate -// method. -type VirtualMachineTemplatesClientBeginCreateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VirtualMachineTemplatesClientBeginDeleteOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginDelete -// method. -type VirtualMachineTemplatesClientBeginDeleteOptions struct { - // Whether force delete was specified. - Force *bool - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VirtualMachineTemplatesClientGetOptions contains the optional parameters for the VirtualMachineTemplatesClient.Get method. -type VirtualMachineTemplatesClientGetOptions struct { - // placeholder for future optional parameters -} - -// VirtualMachineTemplatesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachineTemplatesClient.NewListByResourceGroupPager -// method. -type VirtualMachineTemplatesClientListByResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// VirtualMachineTemplatesClientListOptions contains the optional parameters for the VirtualMachineTemplatesClient.NewListPager -// method. -type VirtualMachineTemplatesClientListOptions struct { - // placeholder for future optional parameters -} - -// VirtualMachineTemplatesClientUpdateOptions contains the optional parameters for the VirtualMachineTemplatesClient.Update -// method. -type VirtualMachineTemplatesClientUpdateOptions struct { - // placeholder for future optional parameters -} - // VirtualMachineTemplatesList - List of VirtualMachineTemplates. type VirtualMachineTemplatesList struct { // REQUIRED; Array of VirtualMachineTemplates @@ -2101,93 +2065,24 @@ type VirtualMachineUpdate struct { Tags map[string]*string } -// VirtualMachineUpdateProperties - Defines the resource properties. +// VirtualMachineUpdateProperties - Describes the properties of a Virtual Machine. type VirtualMachineUpdateProperties struct { - // Defines the resource properties. + // Specifies the guest agent settings for the virtual machine. + GuestAgentProfile *GuestAgentProfileUpdate + + // Specifies the hardware settings for the virtual machine. HardwareProfile *HardwareProfile - // Defines the update resource properties. + // Specifies the network interfaces of the virtual machine. NetworkProfile *NetworkProfileUpdate // OS properties. OSProfile *OsProfileUpdate - // Defines the resource update properties. + // Specifies the storage settings for the virtual machine disks. StorageProfile *StorageProfileUpdate } -// VirtualMachinesClientBeginAssessPatchesOptions contains the optional parameters for the VirtualMachinesClient.BeginAssessPatches -// method. -type VirtualMachinesClientBeginAssessPatchesOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VirtualMachinesClientBeginCreateOptions contains the optional parameters for the VirtualMachinesClient.BeginCreate method. -type VirtualMachinesClientBeginCreateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VirtualMachinesClientBeginDeleteOptions contains the optional parameters for the VirtualMachinesClient.BeginDelete method. -type VirtualMachinesClientBeginDeleteOptions struct { - // Whether force delete was specified. - Force *bool - // Resumes the LRO from the provided token. - ResumeToken string - // Whether to just disable the VM from azure and retain the VM in the VMM. - Retain *bool -} - -// VirtualMachinesClientBeginInstallPatchesOptions contains the optional parameters for the VirtualMachinesClient.BeginInstallPatches -// method. -type VirtualMachinesClientBeginInstallPatchesOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VirtualMachinesClientBeginRestartOptions contains the optional parameters for the VirtualMachinesClient.BeginRestart method. -type VirtualMachinesClientBeginRestartOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VirtualMachinesClientBeginStartOptions contains the optional parameters for the VirtualMachinesClient.BeginStart method. -type VirtualMachinesClientBeginStartOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VirtualMachinesClientBeginStopOptions contains the optional parameters for the VirtualMachinesClient.BeginStop method. -type VirtualMachinesClientBeginStopOptions struct { - // Virtualmachine stop action payload. - Body *StopVirtualMachineOptions - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VirtualMachinesClientBeginUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginUpdate method. -type VirtualMachinesClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VirtualMachinesClientGetOptions contains the optional parameters for the VirtualMachinesClient.Get method. -type VirtualMachinesClientGetOptions struct { - // placeholder for future optional parameters -} - -// VirtualMachinesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachinesClient.NewListByResourceGroupPager -// method. -type VirtualMachinesClientListByResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// VirtualMachinesClientListOptions contains the optional parameters for the VirtualMachinesClient.NewListPager method. -type VirtualMachinesClientListOptions struct { - // placeholder for future optional parameters -} - // VirtualMachinesList - List of VirtualMachines. type VirtualMachinesList struct { // REQUIRED; Array of VirtualMachines @@ -2243,8 +2138,8 @@ type VirtualNetworkInventoryItem struct { // Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. MoRefID *string - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState } // GetInventoryItemProperties implements the InventoryItemPropertiesClassification interface for type VirtualNetworkInventoryItem. @@ -2252,13 +2147,13 @@ func (v *VirtualNetworkInventoryItem) GetInventoryItemProperties() *InventoryIte return &InventoryItemProperties{ InventoryType: v.InventoryType, ManagedResourceID: v.ManagedResourceID, - MoRefID: v.MoRefID, MoName: v.MoName, + MoRefID: v.MoRefID, ProvisioningState: v.ProvisioningState, } } -// VirtualNetworkProperties - Defines the resource properties. +// VirtualNetworkProperties - Describes the properties of a Virtual Network. type VirtualNetworkProperties struct { // Gets or sets the inventory Item ID for the virtual network. InventoryItemID *string @@ -2275,8 +2170,8 @@ type VirtualNetworkProperties struct { // READ-ONLY; Gets or sets the vCenter Managed Object name for the virtual network. MoName *string - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Gets the provisioning state. + ProvisioningState *ProvisioningState // READ-ONLY; The resource status information. Statuses []*ResourceStatus @@ -2285,41 +2180,6 @@ type VirtualNetworkProperties struct { UUID *string } -// VirtualNetworksClientBeginCreateOptions contains the optional parameters for the VirtualNetworksClient.BeginCreate method. -type VirtualNetworksClientBeginCreateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VirtualNetworksClientBeginDeleteOptions contains the optional parameters for the VirtualNetworksClient.BeginDelete method. -type VirtualNetworksClientBeginDeleteOptions struct { - // Whether force delete was specified. - Force *bool - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VirtualNetworksClientGetOptions contains the optional parameters for the VirtualNetworksClient.Get method. -type VirtualNetworksClientGetOptions struct { - // placeholder for future optional parameters -} - -// VirtualNetworksClientListByResourceGroupOptions contains the optional parameters for the VirtualNetworksClient.NewListByResourceGroupPager -// method. -type VirtualNetworksClientListByResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// VirtualNetworksClientListOptions contains the optional parameters for the VirtualNetworksClient.NewListPager method. -type VirtualNetworksClientListOptions struct { - // placeholder for future optional parameters -} - -// VirtualNetworksClientUpdateOptions contains the optional parameters for the VirtualNetworksClient.Update method. -type VirtualNetworksClientUpdateOptions struct { - // placeholder for future optional parameters -} - // VirtualNetworksList - List of VirtualNetworks. type VirtualNetworksList struct { // REQUIRED; Array of VirtualNetworks diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/models_serde.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/models_serde.go index 3986c0f853dd..f638a42c6414 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/models_serde.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/models_serde.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware @@ -196,7 +196,11 @@ func (c ClusterProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "networkIds", c.NetworkIDs) populate(objectMap, "provisioningState", c.ProvisioningState) populate(objectMap, "statuses", c.Statuses) + populate(objectMap, "totalCpuMHz", c.TotalCPUMHz) + populate(objectMap, "totalMemoryGB", c.TotalMemoryGB) populate(objectMap, "uuid", c.UUID) + populate(objectMap, "usedCpuMHz", c.UsedCPUMHz) + populate(objectMap, "usedMemoryGB", c.UsedMemoryGB) populate(objectMap, "vCenterId", c.VCenterID) return json.Marshal(objectMap) } @@ -234,9 +238,21 @@ func (c *ClusterProperties) UnmarshalJSON(data []byte) error { case "statuses": err = unpopulate(val, "Statuses", &c.Statuses) delete(rawMsg, key) + case "totalCpuMHz": + err = unpopulate(val, "TotalCPUMHz", &c.TotalCPUMHz) + delete(rawMsg, key) + case "totalMemoryGB": + err = unpopulate(val, "TotalMemoryGB", &c.TotalMemoryGB) + delete(rawMsg, key) case "uuid": err = unpopulate(val, "UUID", &c.UUID) delete(rawMsg, key) + case "usedCpuMHz": + err = unpopulate(val, "UsedCPUMHz", &c.UsedCPUMHz) + delete(rawMsg, key) + case "usedMemoryGB": + err = unpopulate(val, "UsedMemoryGB", &c.UsedMemoryGB) + delete(rawMsg, key) case "vCenterId": err = unpopulate(val, "VCenterID", &c.VCenterID) delete(rawMsg, key) @@ -392,7 +408,9 @@ func (d *DatastoreInventoryItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DatastoreProperties. func (d DatastoreProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "capacityGB", d.CapacityGB) populate(objectMap, "customResourceName", d.CustomResourceName) + populate(objectMap, "freeSpaceGB", d.FreeSpaceGB) populate(objectMap, "inventoryItemId", d.InventoryItemID) populate(objectMap, "moName", d.MoName) populate(objectMap, "moRefId", d.MoRefID) @@ -412,9 +430,15 @@ func (d *DatastoreProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "capacityGB": + err = unpopulate(val, "CapacityGB", &d.CapacityGB) + delete(rawMsg, key) case "customResourceName": err = unpopulate(val, "CustomResourceName", &d.CustomResourceName) delete(rawMsg, key) + case "freeSpaceGB": + err = unpopulate(val, "FreeSpaceGB", &d.FreeSpaceGB) + delete(rawMsg, key) case "inventoryItemId": err = unpopulate(val, "InventoryItemID", &d.InventoryItemID) delete(rawMsg, key) @@ -475,9 +499,41 @@ func (d *DatastoresList) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "info", e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ErrorDetail. func (e ErrorDetail) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) populate(objectMap, "code", e.Code) populate(objectMap, "details", e.Details) populate(objectMap, "message", e.Message) @@ -494,6 +550,9 @@ func (e *ErrorDetail) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) case "code": err = unpopulate(val, "Code", &e.Code) delete(rawMsg, key) @@ -545,6 +604,33 @@ func (e *ExtendedLocation) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ExtensionTargetProperties. +func (e ExtensionTargetProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "targetVersion", e.TargetVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionTargetProperties. +func (e *ExtensionTargetProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "targetVersion": + err = unpopulate(val, "TargetVersion", &e.TargetVersion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type GuestAgent. func (g GuestAgent) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -623,8 +709,10 @@ func (g *GuestAgentList) UnmarshalJSON(data []byte) error { func (g GuestAgentProfile) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "agentVersion", g.AgentVersion) + populate(objectMap, "clientPublicKey", g.ClientPublicKey) populate(objectMap, "errorDetails", g.ErrorDetails) populateTimeRFC3339(objectMap, "lastStatusChange", g.LastStatusChange) + populate(objectMap, "mssqlDiscovered", g.MssqlDiscovered) populate(objectMap, "status", g.Status) populate(objectMap, "vmUuid", g.VMUUID) return json.Marshal(objectMap) @@ -642,12 +730,18 @@ func (g *GuestAgentProfile) UnmarshalJSON(data []byte) error { case "agentVersion": err = unpopulate(val, "AgentVersion", &g.AgentVersion) delete(rawMsg, key) + case "clientPublicKey": + err = unpopulate(val, "ClientPublicKey", &g.ClientPublicKey) + delete(rawMsg, key) case "errorDetails": err = unpopulate(val, "ErrorDetails", &g.ErrorDetails) delete(rawMsg, key) case "lastStatusChange": err = unpopulateTimeRFC3339(val, "LastStatusChange", &g.LastStatusChange) delete(rawMsg, key) + case "mssqlDiscovered": + err = unpopulate(val, "MssqlDiscovered", &g.MssqlDiscovered) + delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &g.Status) delete(rawMsg, key) @@ -662,12 +756,40 @@ func (g *GuestAgentProfile) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type GuestAgentProfileUpdate. +func (g GuestAgentProfileUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientPublicKey", g.ClientPublicKey) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GuestAgentProfileUpdate. +func (g *GuestAgentProfileUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientPublicKey": + err = unpopulate(val, "ClientPublicKey", &g.ClientPublicKey) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type GuestAgentProperties. func (g GuestAgentProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "credentials", g.Credentials) populate(objectMap, "customResourceName", g.CustomResourceName) populate(objectMap, "httpProxyConfig", g.HTTPProxyConfig) + populate(objectMap, "privateLinkScopeResourceId", g.PrivateLinkScopeResourceID) populate(objectMap, "provisioningAction", g.ProvisioningAction) populate(objectMap, "provisioningState", g.ProvisioningState) populate(objectMap, "status", g.Status) @@ -694,6 +816,9 @@ func (g *GuestAgentProperties) UnmarshalJSON(data []byte) error { case "httpProxyConfig": err = unpopulate(val, "HTTPProxyConfig", &g.HTTPProxyConfig) delete(rawMsg, key) + case "privateLinkScopeResourceId": + err = unpopulate(val, "PrivateLinkScopeResourceID", &g.PrivateLinkScopeResourceID) + delete(rawMsg, key) case "provisioningAction": err = unpopulate(val, "ProvisioningAction", &g.ProvisioningAction) delete(rawMsg, key) @@ -931,10 +1056,16 @@ func (h *HostInventoryItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HostProperties. func (h HostProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "cpuMhz", h.CPUMhz) populate(objectMap, "customResourceName", h.CustomResourceName) + populate(objectMap, "datastoreIds", h.DatastoreIDs) populate(objectMap, "inventoryItemId", h.InventoryItemID) + populate(objectMap, "memorySizeGB", h.MemorySizeGB) populate(objectMap, "moName", h.MoName) populate(objectMap, "moRefId", h.MoRefID) + populate(objectMap, "networkIds", h.NetworkIDs) + populate(objectMap, "overallCpuUsageMHz", h.OverallCPUUsageMHz) + populate(objectMap, "overallMemoryUsageGB", h.OverallMemoryUsageGB) populate(objectMap, "provisioningState", h.ProvisioningState) populate(objectMap, "statuses", h.Statuses) populate(objectMap, "uuid", h.UUID) @@ -951,18 +1082,36 @@ func (h *HostProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "cpuMhz": + err = unpopulate(val, "CPUMhz", &h.CPUMhz) + delete(rawMsg, key) case "customResourceName": err = unpopulate(val, "CustomResourceName", &h.CustomResourceName) delete(rawMsg, key) + case "datastoreIds": + err = unpopulate(val, "DatastoreIDs", &h.DatastoreIDs) + delete(rawMsg, key) case "inventoryItemId": err = unpopulate(val, "InventoryItemID", &h.InventoryItemID) delete(rawMsg, key) + case "memorySizeGB": + err = unpopulate(val, "MemorySizeGB", &h.MemorySizeGB) + delete(rawMsg, key) case "moName": err = unpopulate(val, "MoName", &h.MoName) delete(rawMsg, key) case "moRefId": err = unpopulate(val, "MoRefID", &h.MoRefID) delete(rawMsg, key) + case "networkIds": + err = unpopulate(val, "NetworkIDs", &h.NetworkIDs) + delete(rawMsg, key) + case "overallCpuUsageMHz": + err = unpopulate(val, "OverallCPUUsageMHz", &h.OverallCPUUsageMHz) + delete(rawMsg, key) + case "overallMemoryUsageGB": + err = unpopulate(val, "OverallMemoryUsageGB", &h.OverallMemoryUsageGB) + delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &h.ProvisioningState) delete(rawMsg, key) @@ -1162,6 +1311,69 @@ func (i *Identity) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type InfrastructureProfile. +func (i InfrastructureProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "customResourceName", i.CustomResourceName) + populate(objectMap, "firmwareType", i.FirmwareType) + populate(objectMap, "folderPath", i.FolderPath) + populate(objectMap, "instanceUuid", i.InstanceUUID) + populate(objectMap, "inventoryItemId", i.InventoryItemID) + populate(objectMap, "moName", i.MoName) + populate(objectMap, "moRefId", i.MoRefID) + populate(objectMap, "smbiosUuid", i.SmbiosUUID) + populate(objectMap, "templateId", i.TemplateID) + populate(objectMap, "vCenterId", i.VCenterID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InfrastructureProfile. +func (i *InfrastructureProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "customResourceName": + err = unpopulate(val, "CustomResourceName", &i.CustomResourceName) + delete(rawMsg, key) + case "firmwareType": + err = unpopulate(val, "FirmwareType", &i.FirmwareType) + delete(rawMsg, key) + case "folderPath": + err = unpopulate(val, "FolderPath", &i.FolderPath) + delete(rawMsg, key) + case "instanceUuid": + err = unpopulate(val, "InstanceUUID", &i.InstanceUUID) + delete(rawMsg, key) + case "inventoryItemId": + err = unpopulate(val, "InventoryItemID", &i.InventoryItemID) + delete(rawMsg, key) + case "moName": + err = unpopulate(val, "MoName", &i.MoName) + delete(rawMsg, key) + case "moRefId": + err = unpopulate(val, "MoRefID", &i.MoRefID) + delete(rawMsg, key) + case "smbiosUuid": + err = unpopulate(val, "SmbiosUUID", &i.SmbiosUUID) + delete(rawMsg, key) + case "templateId": + err = unpopulate(val, "TemplateID", &i.TemplateID) + delete(rawMsg, key) + case "vCenterId": + err = unpopulate(val, "VCenterID", &i.VCenterID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type InventoryItem. func (i InventoryItem) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1213,6 +1425,7 @@ func (i *InventoryItem) UnmarshalJSON(data []byte) error { func (i InventoryItemDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "inventoryItemId", i.InventoryItemID) + populate(objectMap, "inventoryType", i.InventoryType) populate(objectMap, "moName", i.MoName) return json.Marshal(objectMap) } @@ -1229,6 +1442,9 @@ func (i *InventoryItemDetails) UnmarshalJSON(data []byte) error { case "inventoryItemId": err = unpopulate(val, "InventoryItemID", &i.InventoryItemID) delete(rawMsg, key) + case "inventoryType": + err = unpopulate(val, "InventoryType", &i.InventoryType) + delete(rawMsg, key) case "moName": err = unpopulate(val, "MoName", &i.MoName) delete(rawMsg, key) @@ -1631,6 +1847,33 @@ func (m *MachineExtensionUpdateProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type MachineExtensionUpgrade. +func (m MachineExtensionUpgrade) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "extensionTargets", m.ExtensionTargets) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MachineExtensionUpgrade. +func (m *MachineExtensionUpgrade) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "extensionTargets": + err = unpopulate(val, "ExtensionTargets", &m.ExtensionTargets) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type MachineExtensionsListResult. func (m MachineExtensionsListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2092,6 +2335,65 @@ func (o *OsProfile) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type OsProfileForVMInstance. +func (o OsProfileForVMInstance) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "adminPassword", o.AdminPassword) + populate(objectMap, "adminUsername", o.AdminUsername) + populate(objectMap, "computerName", o.ComputerName) + populate(objectMap, "guestId", o.GuestID) + populate(objectMap, "osSku", o.OSSKU) + populate(objectMap, "osType", o.OSType) + populate(objectMap, "toolsRunningStatus", o.ToolsRunningStatus) + populate(objectMap, "toolsVersion", o.ToolsVersion) + populate(objectMap, "toolsVersionStatus", o.ToolsVersionStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OsProfileForVMInstance. +func (o *OsProfileForVMInstance) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "adminPassword": + err = unpopulate(val, "AdminPassword", &o.AdminPassword) + delete(rawMsg, key) + case "adminUsername": + err = unpopulate(val, "AdminUsername", &o.AdminUsername) + delete(rawMsg, key) + case "computerName": + err = unpopulate(val, "ComputerName", &o.ComputerName) + delete(rawMsg, key) + case "guestId": + err = unpopulate(val, "GuestID", &o.GuestID) + delete(rawMsg, key) + case "osSku": + err = unpopulate(val, "OSSKU", &o.OSSKU) + delete(rawMsg, key) + case "osType": + err = unpopulate(val, "OSType", &o.OSType) + delete(rawMsg, key) + case "toolsRunningStatus": + err = unpopulate(val, "ToolsRunningStatus", &o.ToolsRunningStatus) + delete(rawMsg, key) + case "toolsVersion": + err = unpopulate(val, "ToolsVersion", &o.ToolsVersion) + delete(rawMsg, key) + case "toolsVersionStatus": + err = unpopulate(val, "ToolsVersionStatus", &o.ToolsVersionStatus) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type OsProfileLinuxConfiguration. func (o OsProfileLinuxConfiguration) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2437,16 +2739,22 @@ func (r *ResourcePoolInventoryItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourcePoolProperties. func (r ResourcePoolProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "cpuCapacityMHz", r.CPUCapacityMHz) populate(objectMap, "cpuLimitMHz", r.CPULimitMHz) + populate(objectMap, "cpuOverallUsageMHz", r.CPUOverallUsageMHz) populate(objectMap, "cpuReservationMHz", r.CPUReservationMHz) populate(objectMap, "cpuSharesLevel", r.CPUSharesLevel) populate(objectMap, "customResourceName", r.CustomResourceName) + populate(objectMap, "datastoreIds", r.DatastoreIDs) populate(objectMap, "inventoryItemId", r.InventoryItemID) + populate(objectMap, "memCapacityGB", r.MemCapacityGB) populate(objectMap, "memLimitMB", r.MemLimitMB) + populate(objectMap, "memOverallUsageGB", r.MemOverallUsageGB) populate(objectMap, "memReservationMB", r.MemReservationMB) populate(objectMap, "memSharesLevel", r.MemSharesLevel) populate(objectMap, "moName", r.MoName) populate(objectMap, "moRefId", r.MoRefID) + populate(objectMap, "networkIds", r.NetworkIDs) populate(objectMap, "provisioningState", r.ProvisioningState) populate(objectMap, "statuses", r.Statuses) populate(objectMap, "uuid", r.UUID) @@ -2463,9 +2771,15 @@ func (r *ResourcePoolProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "cpuCapacityMHz": + err = unpopulate(val, "CPUCapacityMHz", &r.CPUCapacityMHz) + delete(rawMsg, key) case "cpuLimitMHz": err = unpopulate(val, "CPULimitMHz", &r.CPULimitMHz) delete(rawMsg, key) + case "cpuOverallUsageMHz": + err = unpopulate(val, "CPUOverallUsageMHz", &r.CPUOverallUsageMHz) + delete(rawMsg, key) case "cpuReservationMHz": err = unpopulate(val, "CPUReservationMHz", &r.CPUReservationMHz) delete(rawMsg, key) @@ -2475,12 +2789,21 @@ func (r *ResourcePoolProperties) UnmarshalJSON(data []byte) error { case "customResourceName": err = unpopulate(val, "CustomResourceName", &r.CustomResourceName) delete(rawMsg, key) + case "datastoreIds": + err = unpopulate(val, "DatastoreIDs", &r.DatastoreIDs) + delete(rawMsg, key) case "inventoryItemId": err = unpopulate(val, "InventoryItemID", &r.InventoryItemID) delete(rawMsg, key) + case "memCapacityGB": + err = unpopulate(val, "MemCapacityGB", &r.MemCapacityGB) + delete(rawMsg, key) case "memLimitMB": err = unpopulate(val, "MemLimitMB", &r.MemLimitMB) delete(rawMsg, key) + case "memOverallUsageGB": + err = unpopulate(val, "MemOverallUsageGB", &r.MemOverallUsageGB) + delete(rawMsg, key) case "memReservationMB": err = unpopulate(val, "MemReservationMB", &r.MemReservationMB) delete(rawMsg, key) @@ -2493,6 +2816,9 @@ func (r *ResourcePoolProperties) UnmarshalJSON(data []byte) error { case "moRefId": err = unpopulate(val, "MoRefID", &r.MoRefID) delete(rawMsg, key) + case "networkIds": + err = unpopulate(val, "NetworkIDs", &r.NetworkIDs) + delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) delete(rawMsg, key) @@ -2961,6 +3287,115 @@ func (v *VICredential) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type VMInstanceHybridIdentityMetadata. +func (v VMInstanceHybridIdentityMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", v.ID) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "systemData", v.SystemData) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMInstanceHybridIdentityMetadata. +func (v *VMInstanceHybridIdentityMetadata) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &v.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &v.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &v.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &v.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMInstanceHybridIdentityMetadataList. +func (v VMInstanceHybridIdentityMetadataList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMInstanceHybridIdentityMetadataList. +func (v *VMInstanceHybridIdentityMetadataList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &v.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &v.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMInstanceHybridIdentityMetadataProperties. +func (v VMInstanceHybridIdentityMetadataProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "publicKey", v.PublicKey) + populate(objectMap, "resourceUid", v.ResourceUID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMInstanceHybridIdentityMetadataProperties. +func (v *VMInstanceHybridIdentityMetadataProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) + delete(rawMsg, key) + case "publicKey": + err = unpopulate(val, "PublicKey", &v.PublicKey) + delete(rawMsg, key) + case "resourceUid": + err = unpopulate(val, "ResourceUID", &v.ResourceUID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type VirtualDisk. func (v VirtualDisk) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3327,9 +3762,217 @@ func (v *VirtualMachineInstallPatchesResult) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineInstance. +func (v VirtualMachineInstance) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "extendedLocation", v.ExtendedLocation) + populate(objectMap, "id", v.ID) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "systemData", v.SystemData) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineInstance. +func (v *VirtualMachineInstance) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "extendedLocation": + err = unpopulate(val, "ExtendedLocation", &v.ExtendedLocation) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &v.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &v.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &v.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &v.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineInstanceProperties. +func (v VirtualMachineInstanceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "hardwareProfile", v.HardwareProfile) + populate(objectMap, "infrastructureProfile", v.InfrastructureProfile) + populate(objectMap, "networkProfile", v.NetworkProfile) + populate(objectMap, "osProfile", v.OSProfile) + populate(objectMap, "placementProfile", v.PlacementProfile) + populate(objectMap, "powerState", v.PowerState) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "resourceUid", v.ResourceUID) + populate(objectMap, "securityProfile", v.SecurityProfile) + populate(objectMap, "statuses", v.Statuses) + populate(objectMap, "storageProfile", v.StorageProfile) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineInstanceProperties. +func (v *VirtualMachineInstanceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "hardwareProfile": + err = unpopulate(val, "HardwareProfile", &v.HardwareProfile) + delete(rawMsg, key) + case "infrastructureProfile": + err = unpopulate(val, "InfrastructureProfile", &v.InfrastructureProfile) + delete(rawMsg, key) + case "networkProfile": + err = unpopulate(val, "NetworkProfile", &v.NetworkProfile) + delete(rawMsg, key) + case "osProfile": + err = unpopulate(val, "OSProfile", &v.OSProfile) + delete(rawMsg, key) + case "placementProfile": + err = unpopulate(val, "PlacementProfile", &v.PlacementProfile) + delete(rawMsg, key) + case "powerState": + err = unpopulate(val, "PowerState", &v.PowerState) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) + delete(rawMsg, key) + case "resourceUid": + err = unpopulate(val, "ResourceUID", &v.ResourceUID) + delete(rawMsg, key) + case "securityProfile": + err = unpopulate(val, "SecurityProfile", &v.SecurityProfile) + delete(rawMsg, key) + case "statuses": + err = unpopulate(val, "Statuses", &v.Statuses) + delete(rawMsg, key) + case "storageProfile": + err = unpopulate(val, "StorageProfile", &v.StorageProfile) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineInstanceUpdate. +func (v VirtualMachineInstanceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", v.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineInstanceUpdate. +func (v *VirtualMachineInstanceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineInstanceUpdateProperties. +func (v VirtualMachineInstanceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "hardwareProfile", v.HardwareProfile) + populate(objectMap, "networkProfile", v.NetworkProfile) + populate(objectMap, "storageProfile", v.StorageProfile) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineInstanceUpdateProperties. +func (v *VirtualMachineInstanceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "hardwareProfile": + err = unpopulate(val, "HardwareProfile", &v.HardwareProfile) + delete(rawMsg, key) + case "networkProfile": + err = unpopulate(val, "NetworkProfile", &v.NetworkProfile) + delete(rawMsg, key) + case "storageProfile": + err = unpopulate(val, "StorageProfile", &v.StorageProfile) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineInstancesList. +func (v VirtualMachineInstancesList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineInstancesList. +func (v *VirtualMachineInstancesList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &v.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &v.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type VirtualMachineInventoryItem. func (v VirtualMachineInventoryItem) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "cluster", v.Cluster) populate(objectMap, "folderPath", v.FolderPath) populate(objectMap, "host", v.Host) populate(objectMap, "ipAddresses", v.IPAddresses) @@ -3359,6 +4002,9 @@ func (v *VirtualMachineInventoryItem) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "cluster": + err = unpopulate(val, "Cluster", &v.Cluster) + delete(rawMsg, key) case "folderPath": err = unpopulate(val, "FolderPath", &v.FolderPath) delete(rawMsg, key) @@ -3606,6 +4252,8 @@ func (v VirtualMachineTemplateInventoryItem) MarshalJSON() ([]byte, error) { populate(objectMap, "osName", v.OSName) populate(objectMap, "osType", v.OSType) populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "toolsVersion", v.ToolsVersion) + populate(objectMap, "toolsVersionStatus", v.ToolsVersionStatus) return json.Marshal(objectMap) } @@ -3651,6 +4299,12 @@ func (v *VirtualMachineTemplateInventoryItem) UnmarshalJSON(data []byte) error { case "provisioningState": err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) delete(rawMsg, key) + case "toolsVersion": + err = unpopulate(val, "ToolsVersion", &v.ToolsVersion) + delete(rawMsg, key) + case "toolsVersionStatus": + err = unpopulate(val, "ToolsVersionStatus", &v.ToolsVersionStatus) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", v, err) @@ -3827,6 +4481,7 @@ func (v *VirtualMachineUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualMachineUpdateProperties. func (v VirtualMachineUpdateProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "guestAgentProfile", v.GuestAgentProfile) populate(objectMap, "hardwareProfile", v.HardwareProfile) populate(objectMap, "networkProfile", v.NetworkProfile) populate(objectMap, "osProfile", v.OSProfile) @@ -3843,6 +4498,9 @@ func (v *VirtualMachineUpdateProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "guestAgentProfile": + err = unpopulate(val, "GuestAgentProfile", &v.GuestAgentProfile) + delete(rawMsg, key) case "hardwareProfile": err = unpopulate(val, "HardwareProfile", &v.HardwareProfile) delete(rawMsg, key) diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/operations_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/operations_client.go index d78d71bc39e2..59697c669026 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/operations_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/operations_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware @@ -48,7 +48,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - Returns list of all operations. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -86,7 +86,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/operations_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/operations_client_example_test.go deleted file mode 100644 index 56b6b17746d6..000000000000 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/operations_client_example_test.go +++ /dev/null @@ -1,244 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armconnectedvmware_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListOperations.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationsList = armconnectedvmware.OperationsList{ - // Value: []*armconnectedvmware.Operation{ - // { - // Name: to.Ptr("microsoft.vmware/vcenters/Read"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Read vcenters"), - // Operation: to.Ptr("Gets/List vcenters resources"), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("vcenters"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/vcenters/Write"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Writes vcenters"), - // Operation: to.Ptr("Create/update vcenters resources"), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("vcenters"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/vcenters/Delete"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Deletes vcenters"), - // Operation: to.Ptr("Deletes vcenters resource"), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("vcenters"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/resourcepools/Read"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Read resourcepools"), - // Operation: to.Ptr("Gets/List resourcepools resources"), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("resourcepools"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/resourcepools/Write"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Writes resourcepools"), - // Operation: to.Ptr("Create/update resourcepools resources"), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("resourcepools"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/resourcepools/Delete"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Deletes resourcepools"), - // Operation: to.Ptr("Deletes resourcepools resource"), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("resourcepools"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/virtualmachines/Read"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Read virtualmachines"), - // Operation: to.Ptr("Gets/List virtualmachines resources"), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("virtualmachines"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/virtualmachines/Write"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Writes virtualmachines"), - // Operation: to.Ptr("Create/update virtualmachines resources"), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("virtualmachines"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/virtualmachines/Delete"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Deletes virtualmachines"), - // Operation: to.Ptr("Deletes virtualmachines resource"), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("virtualmachines"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/virtualmachinetemplates/Read"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Read virtualmachinetemplates"), - // Operation: to.Ptr("Gets/List virtualmachinetemplates resources"), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("virtualmachinetemplates"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/virtualmachinetemplates/Write"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Writes virtualmachinetemplates"), - // Operation: to.Ptr("Create/update virtualmachinetemplates resources"), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("virtualmachinetemplates"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/virtualmachinetemplates/Delete"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Deletes virtualmachinetemplates"), - // Operation: to.Ptr("Deletes virtualmachinetemplates resource"), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("virtualmachinetemplates"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/virtualnetworks/Read"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Read virtualnetworks"), - // Operation: to.Ptr("Gets/List virtualnetworks resources"), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("virtualnetworks"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/virtualnetworks/Write"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Writes virtualnetworks"), - // Operation: to.Ptr("Create/update virtualnetworks resources"), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("virtualnetworks"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/virtualnetworks/Delete"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Deletes virtualnetworks"), - // Operation: to.Ptr("Deletes virtualnetworks resource"), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("virtualnetworks"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/arczones/deploy/action"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Deploy on arczone."), - // Operation: to.Ptr("Deploy on arczone."), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("arczones"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/virtualmachinetemplates/clone/action"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Clone on virtual machine templates."), - // Operation: to.Ptr("Clone on virtual machine templates."), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("virtualmachinetemplates"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/resourcepools/deploy/action"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Deploy on resource pool."), - // Operation: to.Ptr("Deploy on resource pool."), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("resourcepools"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("microsoft.vmware/virtualnetworks/join/action"), - // Display: &armconnectedvmware.OperationDisplay{ - // Description: to.Ptr("Join virtual network."), - // Operation: to.Ptr("Join virtual network."), - // Provider: to.Ptr("microsoft.vmware"), - // Resource: to.Ptr("virtualnetworks"), - // }, - // IsDataAction: to.Ptr(false), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/options.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/options.go new file mode 100644 index 000000000000..920fe617cf4d --- /dev/null +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/options.go @@ -0,0 +1,558 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package armconnectedvmware + +// AzureArcVMwareManagementServiceAPIClientBeginUpgradeExtensionsOptions contains the optional parameters for the AzureArcVMwareManagementServiceAPIClient.BeginUpgradeExtensions +// method. +type AzureArcVMwareManagementServiceAPIClientBeginUpgradeExtensionsOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ClustersClientBeginCreateOptions contains the optional parameters for the ClustersClient.BeginCreate method. +type ClustersClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ClustersClientBeginDeleteOptions contains the optional parameters for the ClustersClient.BeginDelete method. +type ClustersClientBeginDeleteOptions struct { + // Whether force delete was specified. + Force *bool + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ClustersClientGetOptions contains the optional parameters for the ClustersClient.Get method. +type ClustersClientGetOptions struct { + // placeholder for future optional parameters +} + +// ClustersClientListByResourceGroupOptions contains the optional parameters for the ClustersClient.NewListByResourceGroupPager +// method. +type ClustersClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ClustersClientListOptions contains the optional parameters for the ClustersClient.NewListPager method. +type ClustersClientListOptions struct { + // placeholder for future optional parameters +} + +// ClustersClientUpdateOptions contains the optional parameters for the ClustersClient.Update method. +type ClustersClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// DatastoresClientBeginCreateOptions contains the optional parameters for the DatastoresClient.BeginCreate method. +type DatastoresClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DatastoresClientBeginDeleteOptions contains the optional parameters for the DatastoresClient.BeginDelete method. +type DatastoresClientBeginDeleteOptions struct { + // Whether force delete was specified. + Force *bool + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DatastoresClientGetOptions contains the optional parameters for the DatastoresClient.Get method. +type DatastoresClientGetOptions struct { + // placeholder for future optional parameters +} + +// DatastoresClientListByResourceGroupOptions contains the optional parameters for the DatastoresClient.NewListByResourceGroupPager +// method. +type DatastoresClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// DatastoresClientListOptions contains the optional parameters for the DatastoresClient.NewListPager method. +type DatastoresClientListOptions struct { + // placeholder for future optional parameters +} + +// DatastoresClientUpdateOptions contains the optional parameters for the DatastoresClient.Update method. +type DatastoresClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// GuestAgentsClientBeginCreateOptions contains the optional parameters for the GuestAgentsClient.BeginCreate method. +type GuestAgentsClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// GuestAgentsClientBeginDeleteOptions contains the optional parameters for the GuestAgentsClient.BeginDelete method. +type GuestAgentsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// GuestAgentsClientGetOptions contains the optional parameters for the GuestAgentsClient.Get method. +type GuestAgentsClientGetOptions struct { + // placeholder for future optional parameters +} + +// GuestAgentsClientListOptions contains the optional parameters for the GuestAgentsClient.NewListPager method. +type GuestAgentsClientListOptions struct { + // placeholder for future optional parameters +} + +// HostsClientBeginCreateOptions contains the optional parameters for the HostsClient.BeginCreate method. +type HostsClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// HostsClientBeginDeleteOptions contains the optional parameters for the HostsClient.BeginDelete method. +type HostsClientBeginDeleteOptions struct { + // Whether force delete was specified. + Force *bool + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// HostsClientGetOptions contains the optional parameters for the HostsClient.Get method. +type HostsClientGetOptions struct { + // placeholder for future optional parameters +} + +// HostsClientListByResourceGroupOptions contains the optional parameters for the HostsClient.NewListByResourceGroupPager +// method. +type HostsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// HostsClientListOptions contains the optional parameters for the HostsClient.NewListPager method. +type HostsClientListOptions struct { + // placeholder for future optional parameters +} + +// HostsClientUpdateOptions contains the optional parameters for the HostsClient.Update method. +type HostsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// HybridIdentityMetadataClientCreateOptions contains the optional parameters for the HybridIdentityMetadataClient.Create +// method. +type HybridIdentityMetadataClientCreateOptions struct { + // placeholder for future optional parameters +} + +// HybridIdentityMetadataClientDeleteOptions contains the optional parameters for the HybridIdentityMetadataClient.Delete +// method. +type HybridIdentityMetadataClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// HybridIdentityMetadataClientGetOptions contains the optional parameters for the HybridIdentityMetadataClient.Get method. +type HybridIdentityMetadataClientGetOptions struct { + // placeholder for future optional parameters +} + +// HybridIdentityMetadataClientListOptions contains the optional parameters for the HybridIdentityMetadataClient.NewListPager +// method. +type HybridIdentityMetadataClientListOptions struct { + // placeholder for future optional parameters +} + +// InventoryItemsClientCreateOptions contains the optional parameters for the InventoryItemsClient.Create method. +type InventoryItemsClientCreateOptions struct { + // placeholder for future optional parameters +} + +// InventoryItemsClientDeleteOptions contains the optional parameters for the InventoryItemsClient.Delete method. +type InventoryItemsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// InventoryItemsClientGetOptions contains the optional parameters for the InventoryItemsClient.Get method. +type InventoryItemsClientGetOptions struct { + // placeholder for future optional parameters +} + +// InventoryItemsClientListByVCenterOptions contains the optional parameters for the InventoryItemsClient.NewListByVCenterPager +// method. +type InventoryItemsClientListByVCenterOptions struct { + // placeholder for future optional parameters +} + +// MachineExtensionsClientBeginCreateOrUpdateOptions contains the optional parameters for the MachineExtensionsClient.BeginCreateOrUpdate +// method. +type MachineExtensionsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// MachineExtensionsClientBeginDeleteOptions contains the optional parameters for the MachineExtensionsClient.BeginDelete +// method. +type MachineExtensionsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// MachineExtensionsClientBeginUpdateOptions contains the optional parameters for the MachineExtensionsClient.BeginUpdate +// method. +type MachineExtensionsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// MachineExtensionsClientGetOptions contains the optional parameters for the MachineExtensionsClient.Get method. +type MachineExtensionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// MachineExtensionsClientListOptions contains the optional parameters for the MachineExtensionsClient.NewListPager method. +type MachineExtensionsClientListOptions struct { + // The expand expression to apply on the operation. + Expand *string +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// ResourcePoolsClientBeginCreateOptions contains the optional parameters for the ResourcePoolsClient.BeginCreate method. +type ResourcePoolsClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ResourcePoolsClientBeginDeleteOptions contains the optional parameters for the ResourcePoolsClient.BeginDelete method. +type ResourcePoolsClientBeginDeleteOptions struct { + // Whether force delete was specified. + Force *bool + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ResourcePoolsClientGetOptions contains the optional parameters for the ResourcePoolsClient.Get method. +type ResourcePoolsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ResourcePoolsClientListByResourceGroupOptions contains the optional parameters for the ResourcePoolsClient.NewListByResourceGroupPager +// method. +type ResourcePoolsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ResourcePoolsClientListOptions contains the optional parameters for the ResourcePoolsClient.NewListPager method. +type ResourcePoolsClientListOptions struct { + // placeholder for future optional parameters +} + +// ResourcePoolsClientUpdateOptions contains the optional parameters for the ResourcePoolsClient.Update method. +type ResourcePoolsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// VCentersClientBeginCreateOptions contains the optional parameters for the VCentersClient.BeginCreate method. +type VCentersClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VCentersClientBeginDeleteOptions contains the optional parameters for the VCentersClient.BeginDelete method. +type VCentersClientBeginDeleteOptions struct { + // Whether force delete was specified. + Force *bool + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VCentersClientGetOptions contains the optional parameters for the VCentersClient.Get method. +type VCentersClientGetOptions struct { + // placeholder for future optional parameters +} + +// VCentersClientListByResourceGroupOptions contains the optional parameters for the VCentersClient.NewListByResourceGroupPager +// method. +type VCentersClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// VCentersClientListOptions contains the optional parameters for the VCentersClient.NewListPager method. +type VCentersClientListOptions struct { + // placeholder for future optional parameters +} + +// VCentersClientUpdateOptions contains the optional parameters for the VCentersClient.Update method. +type VCentersClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// VMInstanceGuestAgentsClientBeginCreateOptions contains the optional parameters for the VMInstanceGuestAgentsClient.BeginCreate +// method. +type VMInstanceGuestAgentsClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VMInstanceGuestAgentsClientBeginDeleteOptions contains the optional parameters for the VMInstanceGuestAgentsClient.BeginDelete +// method. +type VMInstanceGuestAgentsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VMInstanceGuestAgentsClientGetOptions contains the optional parameters for the VMInstanceGuestAgentsClient.Get method. +type VMInstanceGuestAgentsClientGetOptions struct { + // placeholder for future optional parameters +} + +// VMInstanceGuestAgentsClientListOptions contains the optional parameters for the VMInstanceGuestAgentsClient.NewListPager +// method. +type VMInstanceGuestAgentsClientListOptions struct { + // placeholder for future optional parameters +} + +// VMInstanceHybridIdentityMetadataClientGetOptions contains the optional parameters for the VMInstanceHybridIdentityMetadataClient.Get +// method. +type VMInstanceHybridIdentityMetadataClientGetOptions struct { + // placeholder for future optional parameters +} + +// VMInstanceHybridIdentityMetadataClientListOptions contains the optional parameters for the VMInstanceHybridIdentityMetadataClient.NewListPager +// method. +type VMInstanceHybridIdentityMetadataClientListOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachineInstancesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginCreateOrUpdate +// method. +type VirtualMachineInstancesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachineInstancesClientBeginDeleteOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginDelete +// method. +type VirtualMachineInstancesClientBeginDeleteOptions struct { + // Whether to delete the VM from the vCenter. + DeleteFromHost *bool + + // Whether force delete was specified. + Force *bool + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachineInstancesClientBeginRestartOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginRestart +// method. +type VirtualMachineInstancesClientBeginRestartOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachineInstancesClientBeginStartOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginStart +// method. +type VirtualMachineInstancesClientBeginStartOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachineInstancesClientBeginStopOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginStop +// method. +type VirtualMachineInstancesClientBeginStopOptions struct { + // Virtualmachine stop action payload. + Body *StopVirtualMachineOptions + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachineInstancesClientBeginUpdateOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginUpdate +// method. +type VirtualMachineInstancesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachineInstancesClientGetOptions contains the optional parameters for the VirtualMachineInstancesClient.Get method. +type VirtualMachineInstancesClientGetOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachineInstancesClientListOptions contains the optional parameters for the VirtualMachineInstancesClient.NewListPager +// method. +type VirtualMachineInstancesClientListOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachineTemplatesClientBeginCreateOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginCreate +// method. +type VirtualMachineTemplatesClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachineTemplatesClientBeginDeleteOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginDelete +// method. +type VirtualMachineTemplatesClientBeginDeleteOptions struct { + // Whether force delete was specified. + Force *bool + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachineTemplatesClientGetOptions contains the optional parameters for the VirtualMachineTemplatesClient.Get method. +type VirtualMachineTemplatesClientGetOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachineTemplatesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachineTemplatesClient.NewListByResourceGroupPager +// method. +type VirtualMachineTemplatesClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachineTemplatesClientListOptions contains the optional parameters for the VirtualMachineTemplatesClient.NewListPager +// method. +type VirtualMachineTemplatesClientListOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachineTemplatesClientUpdateOptions contains the optional parameters for the VirtualMachineTemplatesClient.Update +// method. +type VirtualMachineTemplatesClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachinesClientBeginAssessPatchesOptions contains the optional parameters for the VirtualMachinesClient.BeginAssessPatches +// method. +type VirtualMachinesClientBeginAssessPatchesOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginCreateOrUpdate +// method. +type VirtualMachinesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginDeleteOptions contains the optional parameters for the VirtualMachinesClient.BeginDelete method. +type VirtualMachinesClientBeginDeleteOptions struct { + // Whether to delete the VM from the vCenter. + DeleteFromHost *bool + + // Whether force delete was specified. + Force *bool + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginInstallPatchesOptions contains the optional parameters for the VirtualMachinesClient.BeginInstallPatches +// method. +type VirtualMachinesClientBeginInstallPatchesOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginRestartOptions contains the optional parameters for the VirtualMachinesClient.BeginRestart method. +type VirtualMachinesClientBeginRestartOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginStartOptions contains the optional parameters for the VirtualMachinesClient.BeginStart method. +type VirtualMachinesClientBeginStartOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginStopOptions contains the optional parameters for the VirtualMachinesClient.BeginStop method. +type VirtualMachinesClientBeginStopOptions struct { + // Virtualmachine stop action payload. + Body *StopVirtualMachineOptions + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginUpdate method. +type VirtualMachinesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientGetOptions contains the optional parameters for the VirtualMachinesClient.Get method. +type VirtualMachinesClientGetOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachinesClientListAllOptions contains the optional parameters for the VirtualMachinesClient.NewListAllPager method. +type VirtualMachinesClientListAllOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachinesClientListOptions contains the optional parameters for the VirtualMachinesClient.NewListPager method. +type VirtualMachinesClientListOptions struct { + // placeholder for future optional parameters +} + +// VirtualNetworksClientBeginCreateOptions contains the optional parameters for the VirtualNetworksClient.BeginCreate method. +type VirtualNetworksClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualNetworksClientBeginDeleteOptions contains the optional parameters for the VirtualNetworksClient.BeginDelete method. +type VirtualNetworksClientBeginDeleteOptions struct { + // Whether force delete was specified. + Force *bool + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualNetworksClientGetOptions contains the optional parameters for the VirtualNetworksClient.Get method. +type VirtualNetworksClientGetOptions struct { + // placeholder for future optional parameters +} + +// VirtualNetworksClientListByResourceGroupOptions contains the optional parameters for the VirtualNetworksClient.NewListByResourceGroupPager +// method. +type VirtualNetworksClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// VirtualNetworksClientListOptions contains the optional parameters for the VirtualNetworksClient.NewListPager method. +type VirtualNetworksClientListOptions struct { + // placeholder for future optional parameters +} + +// VirtualNetworksClientUpdateOptions contains the optional parameters for the VirtualNetworksClient.Update method. +type VirtualNetworksClientUpdateOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/polymorphic_helpers.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/polymorphic_helpers.go index 6ddcdb956204..db0b6954bf78 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/polymorphic_helpers.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/polymorphic_helpers.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware @@ -46,5 +46,8 @@ func unmarshalInventoryItemPropertiesClassification(rawMsg json.RawMessage) (Inv default: b = &InventoryItemProperties{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/resourcepools_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/resourcepools_client.go index ebf98b49017e..edc23c545152 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/resourcepools_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/resourcepools_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware @@ -56,7 +56,7 @@ func NewResourcePoolsClient(subscriptionID string, credential azcore.TokenCreden // BeginCreate - Create Or Update resourcePool. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - resourcePoolName - Name of the resourcePool. // - body - Request payload. @@ -68,9 +68,10 @@ func (client *ResourcePoolsClient) BeginCreate(ctx context.Context, resourceGrou if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ResourcePoolsClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ResourcePoolsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ResourcePoolsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -79,20 +80,22 @@ func (client *ResourcePoolsClient) BeginCreate(ctx context.Context, resourceGrou // Create - Create Or Update resourcePool. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *ResourcePoolsClient) create(ctx context.Context, resourceGroupName string, resourcePoolName string, body ResourcePool, options *ResourcePoolsClientBeginCreateOptions) (*http.Response, error) { + var err error req, err := client.createCreateRequest(ctx, resourceGroupName, resourcePoolName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createCreateRequest creates the Create request. @@ -115,16 +118,19 @@ func (client *ResourcePoolsClient) createCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Implements resourcePool DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - resourcePoolName - Name of the resourcePool. // - options - ResourcePoolsClientBeginDeleteOptions contains the optional parameters for the ResourcePoolsClient.BeginDelete @@ -135,7 +141,8 @@ func (client *ResourcePoolsClient) BeginDelete(ctx context.Context, resourceGrou if err != nil { return nil, err } - return runtime.NewPoller[ResourcePoolsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[ResourcePoolsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[ResourcePoolsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -144,20 +151,22 @@ func (client *ResourcePoolsClient) BeginDelete(ctx context.Context, resourceGrou // Delete - Implements resourcePool DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *ResourcePoolsClient) deleteOperation(ctx context.Context, resourceGroupName string, resourcePoolName string, options *ResourcePoolsClientBeginDeleteOptions) (*http.Response, error) { + var err error req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourcePoolName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -180,7 +189,7 @@ func (client *ResourcePoolsClient) deleteCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") if options != nil && options.Force != nil { reqQP.Set("force", strconv.FormatBool(*options.Force)) } @@ -192,23 +201,26 @@ func (client *ResourcePoolsClient) deleteCreateRequest(ctx context.Context, reso // Get - Implements resourcePool GET method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - resourcePoolName - Name of the resourcePool. // - options - ResourcePoolsClientGetOptions contains the optional parameters for the ResourcePoolsClient.Get method. func (client *ResourcePoolsClient) Get(ctx context.Context, resourceGroupName string, resourcePoolName string, options *ResourcePoolsClientGetOptions) (ResourcePoolsClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, resourceGroupName, resourcePoolName, options) if err != nil { return ResourcePoolsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourcePoolsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourcePoolsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ResourcePoolsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -231,7 +243,7 @@ func (client *ResourcePoolsClient) getCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -248,7 +260,7 @@ func (client *ResourcePoolsClient) getHandleResponse(resp *http.Response) (Resou // NewListPager - List of resourcePools in a subscription. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - options - ResourcePoolsClientListOptions contains the optional parameters for the ResourcePoolsClient.NewListPager method. func (client *ResourcePoolsClient) NewListPager(options *ResourcePoolsClientListOptions) *runtime.Pager[ResourcePoolsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ResourcePoolsClientListResponse]{ @@ -290,7 +302,7 @@ func (client *ResourcePoolsClient) listCreateRequest(ctx context.Context, option return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -307,7 +319,7 @@ func (client *ResourcePoolsClient) listHandleResponse(resp *http.Response) (Reso // NewListByResourceGroupPager - List of resourcePools in a resource group. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - options - ResourcePoolsClientListByResourceGroupOptions contains the optional parameters for the ResourcePoolsClient.NewListByResourceGroupPager // method. @@ -355,7 +367,7 @@ func (client *ResourcePoolsClient) listByResourceGroupCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -373,24 +385,27 @@ func (client *ResourcePoolsClient) listByResourceGroupHandleResponse(resp *http. // Update - API to update certain properties of the resourcePool resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - resourcePoolName - Name of the resourcePool. // - body - Resource properties to update. // - options - ResourcePoolsClientUpdateOptions contains the optional parameters for the ResourcePoolsClient.Update method. func (client *ResourcePoolsClient) Update(ctx context.Context, resourceGroupName string, resourcePoolName string, body ResourcePatch, options *ResourcePoolsClientUpdateOptions) (ResourcePoolsClientUpdateResponse, error) { + var err error req, err := client.updateCreateRequest(ctx, resourceGroupName, resourcePoolName, body, options) if err != nil { return ResourcePoolsClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourcePoolsClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourcePoolsClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ResourcePoolsClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -413,10 +428,13 @@ func (client *ResourcePoolsClient) updateCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // updateHandleResponse handles the Update response. diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/resourcepools_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/resourcepools_client_example_test.go deleted file mode 100644 index 3654937b6ba4..000000000000 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/resourcepools_client_example_test.go +++ /dev/null @@ -1,262 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armconnectedvmware_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateResourcePool.json -func ExampleResourcePoolsClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewResourcePoolsClient().BeginCreate(ctx, "testrg", "HRPool", armconnectedvmware.ResourcePool{ - ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - Type: to.Ptr("customLocation"), - }, - Location: to.Ptr("East US"), - Properties: &armconnectedvmware.ResourcePoolProperties{ - MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ResourcePool = armconnectedvmware.ResourcePool{ - // Name: to.Ptr("HRPool"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/ResourcePools"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.ResourcePoolProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetResourcePool.json -func ExampleResourcePoolsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewResourcePoolsClient().Get(ctx, "testrg", "HRPool", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ResourcePool = armconnectedvmware.ResourcePool{ - // Name: to.Ptr("HRPool"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/ResourcePools"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.ResourcePoolProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateResourcePool.json -func ExampleResourcePoolsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewResourcePoolsClient().Update(ctx, "testrg", "HRPool", armconnectedvmware.ResourcePatch{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ResourcePool = armconnectedvmware.ResourcePool{ - // Name: to.Ptr("HRPool"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/ResourcePools"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.ResourcePoolProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteResourcePool.json -func ExampleResourcePoolsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewResourcePoolsClient().BeginDelete(ctx, "testrg", "HRPool", &armconnectedvmware.ResourcePoolsClientBeginDeleteOptions{Force: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListResourcePools.json -func ExampleResourcePoolsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewResourcePoolsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ResourcePoolsList = armconnectedvmware.ResourcePoolsList{ - // Value: []*armconnectedvmware.ResourcePool{ - // { - // Name: to.Ptr("HRPool"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/ResourcePools"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.ResourcePoolProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListResourcePoolsByResourceGroup.json -func ExampleResourcePoolsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewResourcePoolsClient().NewListByResourceGroupPager("testrg", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ResourcePoolsList = armconnectedvmware.ResourcePoolsList{ - // Value: []*armconnectedvmware.ResourcePool{ - // { - // Name: to.Ptr("HRPool"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/ResourcePools"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.ResourcePoolProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/response_types.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/response_types.go index a2f8bbf005a1..05ca50ba0629 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/response_types.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/response_types.go @@ -13,12 +13,18 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware +// AzureArcVMwareManagementServiceAPIClientUpgradeExtensionsResponse contains the response from method AzureArcVMwareManagementServiceAPIClient.BeginUpgradeExtensions. +type AzureArcVMwareManagementServiceAPIClientUpgradeExtensionsResponse struct { + // placeholder for future response values +} + // ClustersClientCreateResponse contains the response from method ClustersClient.BeginCreate. type ClustersClientCreateResponse struct { + // Define the cluster. Cluster } @@ -29,26 +35,31 @@ type ClustersClientDeleteResponse struct { // ClustersClientGetResponse contains the response from method ClustersClient.Get. type ClustersClientGetResponse struct { + // Define the cluster. Cluster } // ClustersClientListByResourceGroupResponse contains the response from method ClustersClient.NewListByResourceGroupPager. type ClustersClientListByResourceGroupResponse struct { + // List of Clusters. ClustersList } // ClustersClientListResponse contains the response from method ClustersClient.NewListPager. type ClustersClientListResponse struct { + // List of Clusters. ClustersList } // ClustersClientUpdateResponse contains the response from method ClustersClient.Update. type ClustersClientUpdateResponse struct { + // Define the cluster. Cluster } // DatastoresClientCreateResponse contains the response from method DatastoresClient.BeginCreate. type DatastoresClientCreateResponse struct { + // Define the datastore. Datastore } @@ -59,26 +70,31 @@ type DatastoresClientDeleteResponse struct { // DatastoresClientGetResponse contains the response from method DatastoresClient.Get. type DatastoresClientGetResponse struct { + // Define the datastore. Datastore } // DatastoresClientListByResourceGroupResponse contains the response from method DatastoresClient.NewListByResourceGroupPager. type DatastoresClientListByResourceGroupResponse struct { + // List of Datastores. DatastoresList } // DatastoresClientListResponse contains the response from method DatastoresClient.NewListPager. type DatastoresClientListResponse struct { + // List of Datastores. DatastoresList } // DatastoresClientUpdateResponse contains the response from method DatastoresClient.Update. type DatastoresClientUpdateResponse struct { + // Define the datastore. Datastore } // GuestAgentsClientCreateResponse contains the response from method GuestAgentsClient.BeginCreate. type GuestAgentsClientCreateResponse struct { + // Defines the GuestAgent. GuestAgent } @@ -89,16 +105,19 @@ type GuestAgentsClientDeleteResponse struct { // GuestAgentsClientGetResponse contains the response from method GuestAgentsClient.Get. type GuestAgentsClientGetResponse struct { + // Defines the GuestAgent. GuestAgent } -// GuestAgentsClientListByVMResponse contains the response from method GuestAgentsClient.NewListByVMPager. -type GuestAgentsClientListByVMResponse struct { +// GuestAgentsClientListResponse contains the response from method GuestAgentsClient.NewListPager. +type GuestAgentsClientListResponse struct { + // List of GuestAgent. GuestAgentList } // HostsClientCreateResponse contains the response from method HostsClient.BeginCreate. type HostsClientCreateResponse struct { + // Define the host. Host } @@ -109,26 +128,31 @@ type HostsClientDeleteResponse struct { // HostsClientGetResponse contains the response from method HostsClient.Get. type HostsClientGetResponse struct { + // Define the host. Host } // HostsClientListByResourceGroupResponse contains the response from method HostsClient.NewListByResourceGroupPager. type HostsClientListByResourceGroupResponse struct { + // List of Hosts. HostsList } // HostsClientListResponse contains the response from method HostsClient.NewListPager. type HostsClientListResponse struct { + // List of Hosts. HostsList } // HostsClientUpdateResponse contains the response from method HostsClient.Update. type HostsClientUpdateResponse struct { + // Define the host. Host } // HybridIdentityMetadataClientCreateResponse contains the response from method HybridIdentityMetadataClient.Create. type HybridIdentityMetadataClientCreateResponse struct { + // Defines the HybridIdentityMetadata. HybridIdentityMetadata } @@ -139,16 +163,19 @@ type HybridIdentityMetadataClientDeleteResponse struct { // HybridIdentityMetadataClientGetResponse contains the response from method HybridIdentityMetadataClient.Get. type HybridIdentityMetadataClientGetResponse struct { + // Defines the HybridIdentityMetadata. HybridIdentityMetadata } -// HybridIdentityMetadataClientListByVMResponse contains the response from method HybridIdentityMetadataClient.NewListByVMPager. -type HybridIdentityMetadataClientListByVMResponse struct { +// HybridIdentityMetadataClientListResponse contains the response from method HybridIdentityMetadataClient.NewListPager. +type HybridIdentityMetadataClientListResponse struct { + // List of HybridIdentityMetadata. HybridIdentityMetadataList } // InventoryItemsClientCreateResponse contains the response from method InventoryItemsClient.Create. type InventoryItemsClientCreateResponse struct { + // Defines the inventory item. InventoryItem } @@ -159,16 +186,19 @@ type InventoryItemsClientDeleteResponse struct { // InventoryItemsClientGetResponse contains the response from method InventoryItemsClient.Get. type InventoryItemsClientGetResponse struct { + // Defines the inventory item. InventoryItem } // InventoryItemsClientListByVCenterResponse contains the response from method InventoryItemsClient.NewListByVCenterPager. type InventoryItemsClientListByVCenterResponse struct { + // List of InventoryItems. InventoryItemsList } // MachineExtensionsClientCreateOrUpdateResponse contains the response from method MachineExtensionsClient.BeginCreateOrUpdate. type MachineExtensionsClientCreateOrUpdateResponse struct { + // Describes a Machine Extension. MachineExtension } @@ -179,26 +209,31 @@ type MachineExtensionsClientDeleteResponse struct { // MachineExtensionsClientGetResponse contains the response from method MachineExtensionsClient.Get. type MachineExtensionsClientGetResponse struct { + // Describes a Machine Extension. MachineExtension } // MachineExtensionsClientListResponse contains the response from method MachineExtensionsClient.NewListPager. type MachineExtensionsClientListResponse struct { + // Describes the Machine Extensions List Result. MachineExtensionsListResult } // MachineExtensionsClientUpdateResponse contains the response from method MachineExtensionsClient.BeginUpdate. type MachineExtensionsClientUpdateResponse struct { + // Describes a Machine Extension. MachineExtension } // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { + // Lists the operations available. OperationsList } // ResourcePoolsClientCreateResponse contains the response from method ResourcePoolsClient.BeginCreate. type ResourcePoolsClientCreateResponse struct { + // Define the resourcePool. ResourcePool } @@ -209,26 +244,31 @@ type ResourcePoolsClientDeleteResponse struct { // ResourcePoolsClientGetResponse contains the response from method ResourcePoolsClient.Get. type ResourcePoolsClientGetResponse struct { + // Define the resourcePool. ResourcePool } // ResourcePoolsClientListByResourceGroupResponse contains the response from method ResourcePoolsClient.NewListByResourceGroupPager. type ResourcePoolsClientListByResourceGroupResponse struct { + // List of ResourcePools. ResourcePoolsList } // ResourcePoolsClientListResponse contains the response from method ResourcePoolsClient.NewListPager. type ResourcePoolsClientListResponse struct { + // List of ResourcePools. ResourcePoolsList } // ResourcePoolsClientUpdateResponse contains the response from method ResourcePoolsClient.Update. type ResourcePoolsClientUpdateResponse struct { + // Define the resourcePool. ResourcePool } // VCentersClientCreateResponse contains the response from method VCentersClient.BeginCreate. type VCentersClientCreateResponse struct { + // Defines the vCenter. VCenter } @@ -239,26 +279,110 @@ type VCentersClientDeleteResponse struct { // VCentersClientGetResponse contains the response from method VCentersClient.Get. type VCentersClientGetResponse struct { + // Defines the vCenter. VCenter } // VCentersClientListByResourceGroupResponse contains the response from method VCentersClient.NewListByResourceGroupPager. type VCentersClientListByResourceGroupResponse struct { + // List of VCenters. VCentersList } // VCentersClientListResponse contains the response from method VCentersClient.NewListPager. type VCentersClientListResponse struct { + // List of VCenters. VCentersList } // VCentersClientUpdateResponse contains the response from method VCentersClient.Update. type VCentersClientUpdateResponse struct { + // Defines the vCenter. VCenter } +// VMInstanceGuestAgentsClientCreateResponse contains the response from method VMInstanceGuestAgentsClient.BeginCreate. +type VMInstanceGuestAgentsClientCreateResponse struct { + // Defines the GuestAgent. + GuestAgent +} + +// VMInstanceGuestAgentsClientDeleteResponse contains the response from method VMInstanceGuestAgentsClient.BeginDelete. +type VMInstanceGuestAgentsClientDeleteResponse struct { + // placeholder for future response values +} + +// VMInstanceGuestAgentsClientGetResponse contains the response from method VMInstanceGuestAgentsClient.Get. +type VMInstanceGuestAgentsClientGetResponse struct { + // Defines the GuestAgent. + GuestAgent +} + +// VMInstanceGuestAgentsClientListResponse contains the response from method VMInstanceGuestAgentsClient.NewListPager. +type VMInstanceGuestAgentsClientListResponse struct { + // List of GuestAgent. + GuestAgentList +} + +// VMInstanceHybridIdentityMetadataClientGetResponse contains the response from method VMInstanceHybridIdentityMetadataClient.Get. +type VMInstanceHybridIdentityMetadataClientGetResponse struct { + // Defines the HybridIdentityMetadata. + VMInstanceHybridIdentityMetadata +} + +// VMInstanceHybridIdentityMetadataClientListResponse contains the response from method VMInstanceHybridIdentityMetadataClient.NewListPager. +type VMInstanceHybridIdentityMetadataClientListResponse struct { + // List of HybridIdentityMetadata. + VMInstanceHybridIdentityMetadataList +} + +// VirtualMachineInstancesClientCreateOrUpdateResponse contains the response from method VirtualMachineInstancesClient.BeginCreateOrUpdate. +type VirtualMachineInstancesClientCreateOrUpdateResponse struct { + // Define the virtualMachineInstance. + VirtualMachineInstance +} + +// VirtualMachineInstancesClientDeleteResponse contains the response from method VirtualMachineInstancesClient.BeginDelete. +type VirtualMachineInstancesClientDeleteResponse struct { + // placeholder for future response values +} + +// VirtualMachineInstancesClientGetResponse contains the response from method VirtualMachineInstancesClient.Get. +type VirtualMachineInstancesClientGetResponse struct { + // Define the virtualMachineInstance. + VirtualMachineInstance +} + +// VirtualMachineInstancesClientListResponse contains the response from method VirtualMachineInstancesClient.NewListPager. +type VirtualMachineInstancesClientListResponse struct { + // List of VirtualMachineInstances. + VirtualMachineInstancesList +} + +// VirtualMachineInstancesClientRestartResponse contains the response from method VirtualMachineInstancesClient.BeginRestart. +type VirtualMachineInstancesClientRestartResponse struct { + // placeholder for future response values +} + +// VirtualMachineInstancesClientStartResponse contains the response from method VirtualMachineInstancesClient.BeginStart. +type VirtualMachineInstancesClientStartResponse struct { + // placeholder for future response values +} + +// VirtualMachineInstancesClientStopResponse contains the response from method VirtualMachineInstancesClient.BeginStop. +type VirtualMachineInstancesClientStopResponse struct { + // placeholder for future response values +} + +// VirtualMachineInstancesClientUpdateResponse contains the response from method VirtualMachineInstancesClient.BeginUpdate. +type VirtualMachineInstancesClientUpdateResponse struct { + // Define the virtualMachineInstance. + VirtualMachineInstance +} + // VirtualMachineTemplatesClientCreateResponse contains the response from method VirtualMachineTemplatesClient.BeginCreate. type VirtualMachineTemplatesClientCreateResponse struct { + // Define the virtualMachineTemplate. VirtualMachineTemplate } @@ -269,31 +393,37 @@ type VirtualMachineTemplatesClientDeleteResponse struct { // VirtualMachineTemplatesClientGetResponse contains the response from method VirtualMachineTemplatesClient.Get. type VirtualMachineTemplatesClientGetResponse struct { + // Define the virtualMachineTemplate. VirtualMachineTemplate } // VirtualMachineTemplatesClientListByResourceGroupResponse contains the response from method VirtualMachineTemplatesClient.NewListByResourceGroupPager. type VirtualMachineTemplatesClientListByResourceGroupResponse struct { + // List of VirtualMachineTemplates. VirtualMachineTemplatesList } // VirtualMachineTemplatesClientListResponse contains the response from method VirtualMachineTemplatesClient.NewListPager. type VirtualMachineTemplatesClientListResponse struct { + // List of VirtualMachineTemplates. VirtualMachineTemplatesList } // VirtualMachineTemplatesClientUpdateResponse contains the response from method VirtualMachineTemplatesClient.Update. type VirtualMachineTemplatesClientUpdateResponse struct { + // Define the virtualMachineTemplate. VirtualMachineTemplate } // VirtualMachinesClientAssessPatchesResponse contains the response from method VirtualMachinesClient.BeginAssessPatches. type VirtualMachinesClientAssessPatchesResponse struct { + // Describes the properties of an AssessPatches result. VirtualMachineAssessPatchesResult } -// VirtualMachinesClientCreateResponse contains the response from method VirtualMachinesClient.BeginCreate. -type VirtualMachinesClientCreateResponse struct { +// VirtualMachinesClientCreateOrUpdateResponse contains the response from method VirtualMachinesClient.BeginCreateOrUpdate. +type VirtualMachinesClientCreateOrUpdateResponse struct { + // Define the virtualMachine. VirtualMachine } @@ -304,21 +434,25 @@ type VirtualMachinesClientDeleteResponse struct { // VirtualMachinesClientGetResponse contains the response from method VirtualMachinesClient.Get. type VirtualMachinesClientGetResponse struct { + // Define the virtualMachine. VirtualMachine } // VirtualMachinesClientInstallPatchesResponse contains the response from method VirtualMachinesClient.BeginInstallPatches. type VirtualMachinesClientInstallPatchesResponse struct { + // The result summary of an installation operation. VirtualMachineInstallPatchesResult } -// VirtualMachinesClientListByResourceGroupResponse contains the response from method VirtualMachinesClient.NewListByResourceGroupPager. -type VirtualMachinesClientListByResourceGroupResponse struct { +// VirtualMachinesClientListAllResponse contains the response from method VirtualMachinesClient.NewListAllPager. +type VirtualMachinesClientListAllResponse struct { + // List of VirtualMachines. VirtualMachinesList } // VirtualMachinesClientListResponse contains the response from method VirtualMachinesClient.NewListPager. type VirtualMachinesClientListResponse struct { + // List of VirtualMachines. VirtualMachinesList } @@ -339,11 +473,13 @@ type VirtualMachinesClientStopResponse struct { // VirtualMachinesClientUpdateResponse contains the response from method VirtualMachinesClient.BeginUpdate. type VirtualMachinesClientUpdateResponse struct { + // Define the virtualMachine. VirtualMachine } // VirtualNetworksClientCreateResponse contains the response from method VirtualNetworksClient.BeginCreate. type VirtualNetworksClientCreateResponse struct { + // Define the virtualNetwork. VirtualNetwork } @@ -354,20 +490,24 @@ type VirtualNetworksClientDeleteResponse struct { // VirtualNetworksClientGetResponse contains the response from method VirtualNetworksClient.Get. type VirtualNetworksClientGetResponse struct { + // Define the virtualNetwork. VirtualNetwork } // VirtualNetworksClientListByResourceGroupResponse contains the response from method VirtualNetworksClient.NewListByResourceGroupPager. type VirtualNetworksClientListByResourceGroupResponse struct { + // List of VirtualNetworks. VirtualNetworksList } // VirtualNetworksClientListResponse contains the response from method VirtualNetworksClient.NewListPager. type VirtualNetworksClientListResponse struct { + // List of VirtualNetworks. VirtualNetworksList } // VirtualNetworksClientUpdateResponse contains the response from method VirtualNetworksClient.Update. type VirtualNetworksClientUpdateResponse struct { + // Define the virtualNetwork. VirtualNetwork } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/time_rfc3339.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/time_rfc3339.go index 6cfa8035aab1..2440c0beec07 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/time_rfc3339.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/time_rfc3339.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/vcenters_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/vcenters_client.go index 585a1529cac9..0dd992d1e2cf 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/vcenters_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/vcenters_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware @@ -56,7 +56,7 @@ func NewVCentersClient(subscriptionID string, credential azcore.TokenCredential, // BeginCreate - Create Or Update vCenter. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - vcenterName - Name of the vCenter. // - body - Request payload. @@ -67,9 +67,10 @@ func (client *VCentersClient) BeginCreate(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VCentersClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VCentersClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[VCentersClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -78,20 +79,22 @@ func (client *VCentersClient) BeginCreate(ctx context.Context, resourceGroupName // Create - Create Or Update vCenter. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *VCentersClient) create(ctx context.Context, resourceGroupName string, vcenterName string, body VCenter, options *VCentersClientBeginCreateOptions) (*http.Response, error) { + var err error req, err := client.createCreateRequest(ctx, resourceGroupName, vcenterName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createCreateRequest creates the Create request. @@ -114,16 +117,19 @@ func (client *VCentersClient) createCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Implements vCenter DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - vcenterName - Name of the vCenter. // - options - VCentersClientBeginDeleteOptions contains the optional parameters for the VCentersClient.BeginDelete method. @@ -133,7 +139,8 @@ func (client *VCentersClient) BeginDelete(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller[VCentersClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[VCentersClientDeleteResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[VCentersClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -142,20 +149,22 @@ func (client *VCentersClient) BeginDelete(ctx context.Context, resourceGroupName // Delete - Implements vCenter DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *VCentersClient) deleteOperation(ctx context.Context, resourceGroupName string, vcenterName string, options *VCentersClientBeginDeleteOptions) (*http.Response, error) { + var err error req, err := client.deleteCreateRequest(ctx, resourceGroupName, vcenterName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -178,7 +187,7 @@ func (client *VCentersClient) deleteCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") if options != nil && options.Force != nil { reqQP.Set("force", strconv.FormatBool(*options.Force)) } @@ -190,23 +199,26 @@ func (client *VCentersClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Implements vCenter GET method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - vcenterName - Name of the vCenter. // - options - VCentersClientGetOptions contains the optional parameters for the VCentersClient.Get method. func (client *VCentersClient) Get(ctx context.Context, resourceGroupName string, vcenterName string, options *VCentersClientGetOptions) (VCentersClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, resourceGroupName, vcenterName, options) if err != nil { return VCentersClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return VCentersClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return VCentersClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VCentersClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -229,7 +241,7 @@ func (client *VCentersClient) getCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -246,7 +258,7 @@ func (client *VCentersClient) getHandleResponse(resp *http.Response) (VCentersCl // NewListPager - List of vCenters in a subscription. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - options - VCentersClientListOptions contains the optional parameters for the VCentersClient.NewListPager method. func (client *VCentersClient) NewListPager(options *VCentersClientListOptions) *runtime.Pager[VCentersClientListResponse] { return runtime.NewPager(runtime.PagingHandler[VCentersClientListResponse]{ @@ -288,7 +300,7 @@ func (client *VCentersClient) listCreateRequest(ctx context.Context, options *VC return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -305,7 +317,7 @@ func (client *VCentersClient) listHandleResponse(resp *http.Response) (VCentersC // NewListByResourceGroupPager - List of vCenters in a resource group. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - options - VCentersClientListByResourceGroupOptions contains the optional parameters for the VCentersClient.NewListByResourceGroupPager // method. @@ -353,7 +365,7 @@ func (client *VCentersClient) listByResourceGroupCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -371,24 +383,27 @@ func (client *VCentersClient) listByResourceGroupHandleResponse(resp *http.Respo // Update - API to update certain properties of the vCenter resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - vcenterName - Name of the vCenter. // - body - Resource properties to update. // - options - VCentersClientUpdateOptions contains the optional parameters for the VCentersClient.Update method. func (client *VCentersClient) Update(ctx context.Context, resourceGroupName string, vcenterName string, body ResourcePatch, options *VCentersClientUpdateOptions) (VCentersClientUpdateResponse, error) { + var err error req, err := client.updateCreateRequest(ctx, resourceGroupName, vcenterName, body, options) if err != nil { return VCentersClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return VCentersClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return VCentersClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VCentersClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -411,10 +426,13 @@ func (client *VCentersClient) updateCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // updateHandleResponse handles the Update response. diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/vcenters_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/vcenters_client_example_test.go deleted file mode 100644 index db5c8b7760bc..000000000000 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/vcenters_client_example_test.go +++ /dev/null @@ -1,291 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armconnectedvmware_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateVCenter.json -func ExampleVCentersClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVCentersClient().BeginCreate(ctx, "testrg", "ContosoVCenter", armconnectedvmware.VCenter{ - ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - Type: to.Ptr("customLocation"), - }, - Location: to.Ptr("East US"), - Properties: &armconnectedvmware.VCenterProperties{ - Credentials: &armconnectedvmware.VICredential{ - Password: to.Ptr(""), - Username: to.Ptr("tempuser"), - }, - Fqdn: to.Ptr("ContosoVMware.contoso.com"), - Port: to.Ptr[int32](1234), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.VCenter = armconnectedvmware.VCenter{ - // Name: to.Ptr("ContosoVCenter"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VCenters"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VCenterProperties{ - // Credentials: &armconnectedvmware.VICredential{ - // Username: to.Ptr("tempuser"), - // }, - // Fqdn: to.Ptr("ContosoVMware.contoso.com"), - // InstanceUUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // Port: to.Ptr[int32](1234), - // ProvisioningState: to.Ptr("Succeeded"), - // Version: to.Ptr("1.0"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetVCenter.json -func ExampleVCentersClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVCentersClient().Get(ctx, "testrg", "ContosoVCenter", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.VCenter = armconnectedvmware.VCenter{ - // Name: to.Ptr("ContosoVCenter"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VCenters"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VCenterProperties{ - // Credentials: &armconnectedvmware.VICredential{ - // Username: to.Ptr("tempuser"), - // }, - // Fqdn: to.Ptr("ContosoVMware.contoso.com"), - // InstanceUUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // Port: to.Ptr[int32](1234), - // ProvisioningState: to.Ptr("Succeeded"), - // Version: to.Ptr("1.0"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateVCenter.json -func ExampleVCentersClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVCentersClient().Update(ctx, "testrg", "ContosoVCenter", armconnectedvmware.ResourcePatch{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.VCenter = armconnectedvmware.VCenter{ - // Name: to.Ptr("ContosoVCenter"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VCenters"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VCenterProperties{ - // Credentials: &armconnectedvmware.VICredential{ - // Username: to.Ptr("tempuser"), - // }, - // Fqdn: to.Ptr("ContosoVMware.contoso.com"), - // InstanceUUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // Port: to.Ptr[int32](1234), - // ProvisioningState: to.Ptr("Succeeded"), - // Version: to.Ptr("1.0"), - // }, - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteVCenter.json -func ExampleVCentersClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVCentersClient().BeginDelete(ctx, "testrg", "ContosoVCenter", &armconnectedvmware.VCentersClientBeginDeleteOptions{Force: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVCenters.json -func ExampleVCentersClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVCentersClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.VCentersList = armconnectedvmware.VCentersList{ - // Value: []*armconnectedvmware.VCenter{ - // { - // Name: to.Ptr("ContosoVCenter"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VCenters"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VCenterProperties{ - // Credentials: &armconnectedvmware.VICredential{ - // Username: to.Ptr("tempuser"), - // }, - // Fqdn: to.Ptr("ContosoVMware.contoso.com"), - // InstanceUUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // Port: to.Ptr[int32](1234), - // ProvisioningState: to.Ptr("Succeeded"), - // Version: to.Ptr("1.0"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVCentersByResourceGroup.json -func ExampleVCentersClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVCentersClient().NewListByResourceGroupPager("testrg", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.VCentersList = armconnectedvmware.VCentersList{ - // Value: []*armconnectedvmware.VCenter{ - // { - // Name: to.Ptr("ContosoVCenter"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VCenters"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VCenterProperties{ - // Credentials: &armconnectedvmware.VICredential{ - // Username: to.Ptr("tempuser"), - // }, - // Fqdn: to.Ptr("ContosoVMware.contoso.com"), - // InstanceUUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // Port: to.Ptr[int32](1234), - // ProvisioningState: to.Ptr("Succeeded"), - // Version: to.Ptr("1.0"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachineinstances_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachineinstances_client.go new file mode 100644 index 000000000000..3ecbc2b9b362 --- /dev/null +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachineinstances_client.go @@ -0,0 +1,526 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package armconnectedvmware + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strconv" + "strings" +) + +// VirtualMachineInstancesClient contains the methods for the VirtualMachineInstances group. +// Don't use this type directly, use NewVirtualMachineInstancesClient() instead. +type VirtualMachineInstancesClient struct { + internal *arm.Client +} + +// NewVirtualMachineInstancesClient creates a new instance of VirtualMachineInstancesClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewVirtualMachineInstancesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualMachineInstancesClient, error) { + cl, err := arm.NewClient(moduleName+".VirtualMachineInstancesClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &VirtualMachineInstancesClient{ + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - The operation to create or update a virtual machine instance. Please note some properties can be +// set only during virtual machine instance creation. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. +// - body - Request payload. +// - options - VirtualMachineInstancesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginCreateOrUpdate +// method. +func (client *VirtualMachineInstancesClient) BeginCreateOrUpdate(ctx context.Context, resourceURI string, body VirtualMachineInstance, options *VirtualMachineInstancesClientBeginCreateOrUpdateOptions) (*runtime.Poller[VirtualMachineInstancesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceURI, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineInstancesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VirtualMachineInstancesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - The operation to create or update a virtual machine instance. Please note some properties can be set only +// during virtual machine instance creation. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *VirtualMachineInstancesClient) createOrUpdate(ctx context.Context, resourceURI string, body VirtualMachineInstance, options *VirtualMachineInstancesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, resourceURI, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *VirtualMachineInstancesClient) createOrUpdateCreateRequest(ctx context.Context, resourceURI string, body VirtualMachineInstance, options *VirtualMachineInstancesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineInstances/default" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - The operation to delete a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. +// - options - VirtualMachineInstancesClientBeginDeleteOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginDelete +// method. +func (client *VirtualMachineInstancesClient) BeginDelete(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientBeginDeleteOptions) (*runtime.Poller[VirtualMachineInstancesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceURI, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineInstancesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VirtualMachineInstancesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - The operation to delete a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *VirtualMachineInstancesClient) deleteOperation(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientBeginDeleteOptions) (*http.Response, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceURI, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *VirtualMachineInstancesClient) deleteCreateRequest(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineInstances/default" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + if options != nil && options.DeleteFromHost != nil { + reqQP.Set("deleteFromHost", strconv.FormatBool(*options.DeleteFromHost)) + } + if options != nil && options.Force != nil { + reqQP.Set("force", strconv.FormatBool(*options.Force)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Retrieves information about a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. +// - options - VirtualMachineInstancesClientGetOptions contains the optional parameters for the VirtualMachineInstancesClient.Get +// method. +func (client *VirtualMachineInstancesClient) Get(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientGetOptions) (VirtualMachineInstancesClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceURI, options) + if err != nil { + return VirtualMachineInstancesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VirtualMachineInstancesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VirtualMachineInstancesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *VirtualMachineInstancesClient) getCreateRequest(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientGetOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineInstances/default" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VirtualMachineInstancesClient) getHandleResponse(resp *http.Response) (VirtualMachineInstancesClientGetResponse, error) { + result := VirtualMachineInstancesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachineInstance); err != nil { + return VirtualMachineInstancesClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Lists all of the virtual machine instances within the specified parent resource. +// +// Generated from API version 2023-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. +// - options - VirtualMachineInstancesClientListOptions contains the optional parameters for the VirtualMachineInstancesClient.NewListPager +// method. +func (client *VirtualMachineInstancesClient) NewListPager(resourceURI string, options *VirtualMachineInstancesClientListOptions) *runtime.Pager[VirtualMachineInstancesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[VirtualMachineInstancesClientListResponse]{ + More: func(page VirtualMachineInstancesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VirtualMachineInstancesClientListResponse) (VirtualMachineInstancesClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceURI, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VirtualMachineInstancesClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VirtualMachineInstancesClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VirtualMachineInstancesClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *VirtualMachineInstancesClient) listCreateRequest(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientListOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineInstances" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *VirtualMachineInstancesClient) listHandleResponse(resp *http.Response) (VirtualMachineInstancesClientListResponse, error) { + result := VirtualMachineInstancesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachineInstancesList); err != nil { + return VirtualMachineInstancesClientListResponse{}, err + } + return result, nil +} + +// BeginRestart - The operation to restart a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. +// - options - VirtualMachineInstancesClientBeginRestartOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginRestart +// method. +func (client *VirtualMachineInstancesClient) BeginRestart(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientBeginRestartOptions) (*runtime.Poller[VirtualMachineInstancesClientRestartResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.restart(ctx, resourceURI, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineInstancesClientRestartResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VirtualMachineInstancesClientRestartResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Restart - The operation to restart a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *VirtualMachineInstancesClient) restart(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientBeginRestartOptions) (*http.Response, error) { + var err error + req, err := client.restartCreateRequest(ctx, resourceURI, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// restartCreateRequest creates the Restart request. +func (client *VirtualMachineInstancesClient) restartCreateRequest(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientBeginRestartOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineInstances/default/restart" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginStart - The operation to start a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. +// - options - VirtualMachineInstancesClientBeginStartOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginStart +// method. +func (client *VirtualMachineInstancesClient) BeginStart(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientBeginStartOptions) (*runtime.Poller[VirtualMachineInstancesClientStartResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.start(ctx, resourceURI, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineInstancesClientStartResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VirtualMachineInstancesClientStartResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Start - The operation to start a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *VirtualMachineInstancesClient) start(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientBeginStartOptions) (*http.Response, error) { + var err error + req, err := client.startCreateRequest(ctx, resourceURI, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// startCreateRequest creates the Start request. +func (client *VirtualMachineInstancesClient) startCreateRequest(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientBeginStartOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineInstances/default/start" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginStop - The operation to power off (stop) a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. +// - options - VirtualMachineInstancesClientBeginStopOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginStop +// method. +func (client *VirtualMachineInstancesClient) BeginStop(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientBeginStopOptions) (*runtime.Poller[VirtualMachineInstancesClientStopResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.stop(ctx, resourceURI, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineInstancesClientStopResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VirtualMachineInstancesClientStopResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Stop - The operation to power off (stop) a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *VirtualMachineInstancesClient) stop(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientBeginStopOptions) (*http.Response, error) { + var err error + req, err := client.stopCreateRequest(ctx, resourceURI, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// stopCreateRequest creates the Stop request. +func (client *VirtualMachineInstancesClient) stopCreateRequest(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientBeginStopOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineInstances/default/stop" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.Body != nil { + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil + } + return req, nil +} + +// BeginUpdate - The operation to update a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. +// - body - Resource properties to update. +// - options - VirtualMachineInstancesClientBeginUpdateOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginUpdate +// method. +func (client *VirtualMachineInstancesClient) BeginUpdate(ctx context.Context, resourceURI string, body VirtualMachineInstanceUpdate, options *VirtualMachineInstancesClientBeginUpdateOptions) (*runtime.Poller[VirtualMachineInstancesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceURI, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineInstancesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VirtualMachineInstancesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - The operation to update a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *VirtualMachineInstancesClient) update(ctx context.Context, resourceURI string, body VirtualMachineInstanceUpdate, options *VirtualMachineInstancesClientBeginUpdateOptions) (*http.Response, error) { + var err error + req, err := client.updateCreateRequest(ctx, resourceURI, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *VirtualMachineInstancesClient) updateCreateRequest(ctx context.Context, resourceURI string, body VirtualMachineInstanceUpdate, options *VirtualMachineInstancesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineInstances/default" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachines_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachines_client.go index 559fc6a1aa7e..41b66e98f734 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachines_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachines_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware @@ -56,20 +56,21 @@ func NewVirtualMachinesClient(subscriptionID string, credential azcore.TokenCred // BeginAssessPatches - The operation to assess patches on a vSphere VMware machine identity in Azure. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The name of the resource group. -// - name - The name of the vSphere VMware machine. +// - virtualMachineName - The name of the vSphere VMware machine. // - options - VirtualMachinesClientBeginAssessPatchesOptions contains the optional parameters for the VirtualMachinesClient.BeginAssessPatches // method. -func (client *VirtualMachinesClient) BeginAssessPatches(ctx context.Context, resourceGroupName string, name string, options *VirtualMachinesClientBeginAssessPatchesOptions) (*runtime.Poller[VirtualMachinesClientAssessPatchesResponse], error) { +func (client *VirtualMachinesClient) BeginAssessPatches(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginAssessPatchesOptions) (*runtime.Poller[VirtualMachinesClientAssessPatchesResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.assessPatches(ctx, resourceGroupName, name, options) + resp, err := client.assessPatches(ctx, resourceGroupName, virtualMachineName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientAssessPatchesResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientAssessPatchesResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[VirtualMachinesClientAssessPatchesResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -78,25 +79,27 @@ func (client *VirtualMachinesClient) BeginAssessPatches(ctx context.Context, res // AssessPatches - The operation to assess patches on a vSphere VMware machine identity in Azure. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview -func (client *VirtualMachinesClient) assessPatches(ctx context.Context, resourceGroupName string, name string, options *VirtualMachinesClientBeginAssessPatchesOptions) (*http.Response, error) { - req, err := client.assessPatchesCreateRequest(ctx, resourceGroupName, name, options) +// Generated from API version 2023-03-01-preview +func (client *VirtualMachinesClient) assessPatches(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginAssessPatchesOptions) (*http.Response, error) { + var err error + req, err := client.assessPatchesCreateRequest(ctx, resourceGroupName, virtualMachineName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // assessPatchesCreateRequest creates the AssessPatches request. -func (client *VirtualMachinesClient) assessPatchesCreateRequest(ctx context.Context, resourceGroupName string, name string, options *VirtualMachinesClientBeginAssessPatchesOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/assessPatches" +func (client *VirtualMachinesClient) assessPatchesCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginAssessPatchesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/assessPatches" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -105,65 +108,68 @@ func (client *VirtualMachinesClient) assessPatchesCreateRequest(ctx context.Cont return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if name == "" { - return nil, errors.New("parameter name cannot be empty") + if virtualMachineName == "" { + return nil, errors.New("parameter virtualMachineName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// BeginCreate - Create Or Update virtual machine. +// BeginCreateOrUpdate - Create Or Update virtual machine. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineName - Name of the virtual machine resource. // - body - Request payload. -// - options - VirtualMachinesClientBeginCreateOptions contains the optional parameters for the VirtualMachinesClient.BeginCreate +// - options - VirtualMachinesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginCreateOrUpdate // method. -func (client *VirtualMachinesClient) BeginCreate(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachine, options *VirtualMachinesClientBeginCreateOptions) (*runtime.Poller[VirtualMachinesClientCreateResponse], error) { +func (client *VirtualMachinesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachine, options *VirtualMachinesClientBeginCreateOrUpdateOptions) (*runtime.Poller[VirtualMachinesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.create(ctx, resourceGroupName, virtualMachineName, body, options) + resp, err := client.createOrUpdate(ctx, resourceGroupName, virtualMachineName, body, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } -// Create - Create Or Update virtual machine. +// CreateOrUpdate - Create Or Update virtual machine. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview -func (client *VirtualMachinesClient) create(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachine, options *VirtualMachinesClientBeginCreateOptions) (*http.Response, error) { - req, err := client.createCreateRequest(ctx, resourceGroupName, virtualMachineName, body, options) +// Generated from API version 2023-03-01-preview +func (client *VirtualMachinesClient) createOrUpdate(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachine, options *VirtualMachinesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, virtualMachineName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } -// createCreateRequest creates the Create request. -func (client *VirtualMachinesClient) createCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachine, options *VirtualMachinesClientBeginCreateOptions) (*policy.Request, error) { +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *VirtualMachinesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachine, options *VirtualMachinesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -182,16 +188,19 @@ func (client *VirtualMachinesClient) createCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Implements virtual machine DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineName - Name of the virtual machine resource. // - options - VirtualMachinesClientBeginDeleteOptions contains the optional parameters for the VirtualMachinesClient.BeginDelete @@ -202,7 +211,8 @@ func (client *VirtualMachinesClient) BeginDelete(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[VirtualMachinesClientDeleteResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[VirtualMachinesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -211,20 +221,22 @@ func (client *VirtualMachinesClient) BeginDelete(ctx context.Context, resourceGr // Delete - Implements virtual machine DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *VirtualMachinesClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteOptions) (*http.Response, error) { + var err error req, err := client.deleteCreateRequest(ctx, resourceGroupName, virtualMachineName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -247,13 +259,13 @@ func (client *VirtualMachinesClient) deleteCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") + if options != nil && options.DeleteFromHost != nil { + reqQP.Set("deleteFromHost", strconv.FormatBool(*options.DeleteFromHost)) + } if options != nil && options.Force != nil { reqQP.Set("force", strconv.FormatBool(*options.Force)) } - if options != nil && options.Retain != nil { - reqQP.Set("retain", strconv.FormatBool(*options.Retain)) - } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -262,23 +274,26 @@ func (client *VirtualMachinesClient) deleteCreateRequest(ctx context.Context, re // Get - Implements virtual machine GET method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineName - Name of the virtual machine resource. // - options - VirtualMachinesClientGetOptions contains the optional parameters for the VirtualMachinesClient.Get method. func (client *VirtualMachinesClient) Get(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientGetOptions) (VirtualMachinesClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, resourceGroupName, virtualMachineName, options) if err != nil { return VirtualMachinesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachinesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return VirtualMachinesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VirtualMachinesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -301,7 +316,7 @@ func (client *VirtualMachinesClient) getCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -319,21 +334,22 @@ func (client *VirtualMachinesClient) getHandleResponse(resp *http.Response) (Vir // BeginInstallPatches - The operation to install patches on a vSphere VMware machine identity in Azure. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The name of the resource group. -// - name - The name of the vSphere VMware machine. +// - virtualMachineName - The name of the vSphere VMware machine. // - installPatchesInput - Input for InstallPatches as directly received by the API // - options - VirtualMachinesClientBeginInstallPatchesOptions contains the optional parameters for the VirtualMachinesClient.BeginInstallPatches // method. -func (client *VirtualMachinesClient) BeginInstallPatches(ctx context.Context, resourceGroupName string, name string, installPatchesInput VirtualMachineInstallPatchesParameters, options *VirtualMachinesClientBeginInstallPatchesOptions) (*runtime.Poller[VirtualMachinesClientInstallPatchesResponse], error) { +func (client *VirtualMachinesClient) BeginInstallPatches(ctx context.Context, resourceGroupName string, virtualMachineName string, installPatchesInput VirtualMachineInstallPatchesParameters, options *VirtualMachinesClientBeginInstallPatchesOptions) (*runtime.Poller[VirtualMachinesClientInstallPatchesResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.installPatches(ctx, resourceGroupName, name, installPatchesInput, options) + resp, err := client.installPatches(ctx, resourceGroupName, virtualMachineName, installPatchesInput, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientInstallPatchesResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientInstallPatchesResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[VirtualMachinesClientInstallPatchesResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -342,25 +358,27 @@ func (client *VirtualMachinesClient) BeginInstallPatches(ctx context.Context, re // InstallPatches - The operation to install patches on a vSphere VMware machine identity in Azure. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview -func (client *VirtualMachinesClient) installPatches(ctx context.Context, resourceGroupName string, name string, installPatchesInput VirtualMachineInstallPatchesParameters, options *VirtualMachinesClientBeginInstallPatchesOptions) (*http.Response, error) { - req, err := client.installPatchesCreateRequest(ctx, resourceGroupName, name, installPatchesInput, options) +// Generated from API version 2023-03-01-preview +func (client *VirtualMachinesClient) installPatches(ctx context.Context, resourceGroupName string, virtualMachineName string, installPatchesInput VirtualMachineInstallPatchesParameters, options *VirtualMachinesClientBeginInstallPatchesOptions) (*http.Response, error) { + var err error + req, err := client.installPatchesCreateRequest(ctx, resourceGroupName, virtualMachineName, installPatchesInput, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // installPatchesCreateRequest creates the InstallPatches request. -func (client *VirtualMachinesClient) installPatchesCreateRequest(ctx context.Context, resourceGroupName string, name string, installPatchesInput VirtualMachineInstallPatchesParameters, options *VirtualMachinesClientBeginInstallPatchesOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/installPatches" +func (client *VirtualMachinesClient) installPatchesCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, installPatchesInput VirtualMachineInstallPatchesParameters, options *VirtualMachinesClientBeginInstallPatchesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/installPatches" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -369,27 +387,31 @@ func (client *VirtualMachinesClient) installPatchesCreateRequest(ctx context.Con return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if name == "" { - return nil, errors.New("parameter name cannot be empty") + if virtualMachineName == "" { + return nil, errors.New("parameter virtualMachineName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) + urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, installPatchesInput) + if err := runtime.MarshalAsJSON(req, installPatchesInput); err != nil { + return nil, err + } + return req, nil } -// NewListPager - List of virtualMachines in a subscription. +// NewListPager - List of virtualMachines in a resource group. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview +// - resourceGroupName - The Resource Group Name. // - options - VirtualMachinesClientListOptions contains the optional parameters for the VirtualMachinesClient.NewListPager // method. -func (client *VirtualMachinesClient) NewListPager(options *VirtualMachinesClientListOptions) *runtime.Pager[VirtualMachinesClientListResponse] { +func (client *VirtualMachinesClient) NewListPager(resourceGroupName string, options *VirtualMachinesClientListOptions) *runtime.Pager[VirtualMachinesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualMachinesClientListResponse]{ More: func(page VirtualMachinesClientListResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 @@ -398,7 +420,7 @@ func (client *VirtualMachinesClient) NewListPager(options *VirtualMachinesClient var req *policy.Request var err error if page == nil { - req, err = client.listCreateRequest(ctx, options) + req, err = client.listCreateRequest(ctx, resourceGroupName, options) } else { req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) } @@ -418,18 +440,22 @@ func (client *VirtualMachinesClient) NewListPager(options *VirtualMachinesClient } // listCreateRequest creates the List request. -func (client *VirtualMachinesClient) listCreateRequest(ctx context.Context, options *VirtualMachinesClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines" +func (client *VirtualMachinesClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *VirtualMachinesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -444,67 +470,62 @@ func (client *VirtualMachinesClient) listHandleResponse(resp *http.Response) (Vi return result, nil } -// NewListByResourceGroupPager - List of virtualMachines in a resource group. +// NewListAllPager - List of virtualMachines in a subscription. // -// Generated from API version 2022-01-10-preview -// - resourceGroupName - The Resource Group Name. -// - options - VirtualMachinesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachinesClient.NewListByResourceGroupPager +// Generated from API version 2023-03-01-preview +// - options - VirtualMachinesClientListAllOptions contains the optional parameters for the VirtualMachinesClient.NewListAllPager // method. -func (client *VirtualMachinesClient) NewListByResourceGroupPager(resourceGroupName string, options *VirtualMachinesClientListByResourceGroupOptions) *runtime.Pager[VirtualMachinesClientListByResourceGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[VirtualMachinesClientListByResourceGroupResponse]{ - More: func(page VirtualMachinesClientListByResourceGroupResponse) bool { +func (client *VirtualMachinesClient) NewListAllPager(options *VirtualMachinesClientListAllOptions) *runtime.Pager[VirtualMachinesClientListAllResponse] { + return runtime.NewPager(runtime.PagingHandler[VirtualMachinesClientListAllResponse]{ + More: func(page VirtualMachinesClientListAllResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *VirtualMachinesClientListByResourceGroupResponse) (VirtualMachinesClientListByResourceGroupResponse, error) { + Fetcher: func(ctx context.Context, page *VirtualMachinesClientListAllResponse) (VirtualMachinesClientListAllResponse, error) { var req *policy.Request var err error if page == nil { - req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + req, err = client.listAllCreateRequest(ctx, options) } else { req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) } if err != nil { - return VirtualMachinesClientListByResourceGroupResponse{}, err + return VirtualMachinesClientListAllResponse{}, err } resp, err := client.internal.Pipeline().Do(req) if err != nil { - return VirtualMachinesClientListByResourceGroupResponse{}, err + return VirtualMachinesClientListAllResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return VirtualMachinesClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + return VirtualMachinesClientListAllResponse{}, runtime.NewResponseError(resp) } - return client.listByResourceGroupHandleResponse(resp) + return client.listAllHandleResponse(resp) }, }) } -// listByResourceGroupCreateRequest creates the ListByResourceGroup request. -func (client *VirtualMachinesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *VirtualMachinesClientListByResourceGroupOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines" +// listAllCreateRequest creates the ListAll request. +func (client *VirtualMachinesClient) listAllCreateRequest(ctx context.Context, options *VirtualMachinesClientListAllOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// listByResourceGroupHandleResponse handles the ListByResourceGroup response. -func (client *VirtualMachinesClient) listByResourceGroupHandleResponse(resp *http.Response) (VirtualMachinesClientListByResourceGroupResponse, error) { - result := VirtualMachinesClientListByResourceGroupResponse{} +// listAllHandleResponse handles the ListAll response. +func (client *VirtualMachinesClient) listAllHandleResponse(resp *http.Response) (VirtualMachinesClientListAllResponse, error) { + result := VirtualMachinesClientListAllResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachinesList); err != nil { - return VirtualMachinesClientListByResourceGroupResponse{}, err + return VirtualMachinesClientListAllResponse{}, err } return result, nil } @@ -512,7 +533,7 @@ func (client *VirtualMachinesClient) listByResourceGroupHandleResponse(resp *htt // BeginRestart - Restart virtual machine. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineName - Name of the virtual machine resource. // - options - VirtualMachinesClientBeginRestartOptions contains the optional parameters for the VirtualMachinesClient.BeginRestart @@ -523,7 +544,10 @@ func (client *VirtualMachinesClient) BeginRestart(ctx context.Context, resourceG if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientRestartResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientRestartResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err } else { return runtime.NewPollerFromResumeToken[VirtualMachinesClientRestartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -532,20 +556,22 @@ func (client *VirtualMachinesClient) BeginRestart(ctx context.Context, resourceG // Restart - Restart virtual machine. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *VirtualMachinesClient) restart(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginRestartOptions) (*http.Response, error) { + var err error req, err := client.restartCreateRequest(ctx, resourceGroupName, virtualMachineName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // restartCreateRequest creates the Restart request. @@ -568,7 +594,7 @@ func (client *VirtualMachinesClient) restartCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -577,7 +603,7 @@ func (client *VirtualMachinesClient) restartCreateRequest(ctx context.Context, r // BeginStart - Start virtual machine. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineName - Name of the virtual machine resource. // - options - VirtualMachinesClientBeginStartOptions contains the optional parameters for the VirtualMachinesClient.BeginStart @@ -588,7 +614,10 @@ func (client *VirtualMachinesClient) BeginStart(ctx context.Context, resourceGro if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientStartResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientStartResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err } else { return runtime.NewPollerFromResumeToken[VirtualMachinesClientStartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -597,20 +626,22 @@ func (client *VirtualMachinesClient) BeginStart(ctx context.Context, resourceGro // Start - Start virtual machine. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *VirtualMachinesClient) start(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStartOptions) (*http.Response, error) { + var err error req, err := client.startCreateRequest(ctx, resourceGroupName, virtualMachineName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // startCreateRequest creates the Start request. @@ -633,7 +664,7 @@ func (client *VirtualMachinesClient) startCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -642,7 +673,7 @@ func (client *VirtualMachinesClient) startCreateRequest(ctx context.Context, res // BeginStop - Stop virtual machine. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineName - Name of the virtual machine resource. // - options - VirtualMachinesClientBeginStopOptions contains the optional parameters for the VirtualMachinesClient.BeginStop @@ -653,7 +684,10 @@ func (client *VirtualMachinesClient) BeginStop(ctx context.Context, resourceGrou if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientStopResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientStopResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err } else { return runtime.NewPollerFromResumeToken[VirtualMachinesClientStopResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -662,20 +696,22 @@ func (client *VirtualMachinesClient) BeginStop(ctx context.Context, resourceGrou // Stop - Stop virtual machine. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *VirtualMachinesClient) stop(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStopOptions) (*http.Response, error) { + var err error req, err := client.stopCreateRequest(ctx, resourceGroupName, virtualMachineName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // stopCreateRequest creates the Stop request. @@ -698,11 +734,14 @@ func (client *VirtualMachinesClient) stopCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -710,7 +749,7 @@ func (client *VirtualMachinesClient) stopCreateRequest(ctx context.Context, reso // BeginUpdate - API to update certain properties of the virtual machine resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineName - Name of the virtual machine resource. // - body - Resource properties to update. @@ -722,7 +761,8 @@ func (client *VirtualMachinesClient) BeginUpdate(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[VirtualMachinesClientUpdateResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[VirtualMachinesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -731,20 +771,22 @@ func (client *VirtualMachinesClient) BeginUpdate(ctx context.Context, resourceGr // Update - API to update certain properties of the virtual machine resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *VirtualMachinesClient) update(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachineUpdate, options *VirtualMachinesClientBeginUpdateOptions) (*http.Response, error) { + var err error req, err := client.updateCreateRequest(ctx, resourceGroupName, virtualMachineName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // updateCreateRequest creates the Update request. @@ -767,8 +809,11 @@ func (client *VirtualMachinesClient) updateCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachines_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachines_client_example_test.go deleted file mode 100644 index 80a297d6b962..000000000000 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachines_client_example_test.go +++ /dev/null @@ -1,482 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armconnectedvmware_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/VirtualMachineAssessPatches.json -func ExampleVirtualMachinesClient_BeginAssessPatches() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachinesClient().BeginAssessPatches(ctx, "myResourceGroupName", "myMachineName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.VirtualMachineAssessPatchesResult = armconnectedvmware.VirtualMachineAssessPatchesResult{ - // AssessmentActivityID: to.Ptr("68f8b292-dfc2-4646-9781-33cc88631968"), - // AvailablePatchCountByClassification: &armconnectedvmware.AvailablePatchCountByClassification{ - // Critical: to.Ptr[int32](0), - // Definition: to.Ptr[int32](0), - // FeaturePack: to.Ptr[int32](0), - // Security: to.Ptr[int32](0), - // ServicePack: to.Ptr[int32](0), - // Tools: to.Ptr[int32](0), - // UpdateRollup: to.Ptr[int32](1), - // Updates: to.Ptr[int32](1), - // }, - // LastModifiedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-15T02:16:06.9740000Z"); return t}()), - // OSType: to.Ptr(armconnectedvmware.OsTypeUMWindows), - // RebootPending: to.Ptr(true), - // StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-15T02:15:20.9340000Z"); return t}()), - // StartedBy: to.Ptr(armconnectedvmware.PatchOperationStartedByUser), - // Status: to.Ptr(armconnectedvmware.PatchOperationStatusSucceeded), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/VirtualMachineInstallPatches.json -func ExampleVirtualMachinesClient_BeginInstallPatches() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachinesClient().BeginInstallPatches(ctx, "myResourceGroupName", "myMachineName", armconnectedvmware.VirtualMachineInstallPatchesParameters{ - MaximumDuration: to.Ptr("PT3H"), - RebootSetting: to.Ptr(armconnectedvmware.VMGuestPatchRebootSettingIfRequired), - WindowsParameters: &armconnectedvmware.WindowsParameters{ - ClassificationsToInclude: []*armconnectedvmware.VMGuestPatchClassificationWindows{ - to.Ptr(armconnectedvmware.VMGuestPatchClassificationWindowsCritical), - to.Ptr(armconnectedvmware.VMGuestPatchClassificationWindowsSecurity)}, - MaxPatchPublishDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-15T02:36:43.0539904+00:00"); return t }()), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.VirtualMachineInstallPatchesResult = armconnectedvmware.VirtualMachineInstallPatchesResult{ - // ExcludedPatchCount: to.Ptr[int32](0), - // FailedPatchCount: to.Ptr[int32](0), - // InstallationActivityID: to.Ptr("68f8b292-dfc2-4646-9781-33cc88631968"), - // InstalledPatchCount: to.Ptr[int32](3), - // LastModifiedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-15T02:16:06.9740000Z"); return t}()), - // MaintenanceWindowExceeded: to.Ptr(false), - // NotSelectedPatchCount: to.Ptr[int32](0), - // OSType: to.Ptr(armconnectedvmware.OsTypeUMWindows), - // PendingPatchCount: to.Ptr[int32](2), - // RebootStatus: to.Ptr(armconnectedvmware.VMGuestPatchRebootStatusCompleted), - // StartDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-01-15T02:15:06.9740000Z"); return t}()), - // StartedBy: to.Ptr(armconnectedvmware.PatchOperationStartedByUser), - // Status: to.Ptr(armconnectedvmware.PatchOperationStatusSucceeded), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateVirtualMachine.json -func ExampleVirtualMachinesClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachinesClient().BeginCreate(ctx, "testrg", "DemoVM", armconnectedvmware.VirtualMachine{ - ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - Type: to.Ptr("customLocation"), - }, - Location: to.Ptr("East US"), - Properties: &armconnectedvmware.VirtualMachineProperties{ - HardwareProfile: &armconnectedvmware.HardwareProfile{ - MemorySizeMB: to.Ptr[int32](4196), - NumCPUs: to.Ptr[int32](4), - }, - ResourcePoolID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), - TemplateID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), - VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.VirtualMachine = armconnectedvmware.VirtualMachine{ - // Name: to.Ptr("DemoVM"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachines/DemoVM"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VirtualMachineProperties{ - // HardwareProfile: &armconnectedvmware.HardwareProfile{ - // MemorySizeMB: to.Ptr[int32](4196), - // NumCPUs: to.Ptr[int32](4), - // }, - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // OSProfile: &armconnectedvmware.OsProfile{ - // ComputerName: to.Ptr("DemoVM"), - // OSType: to.Ptr(armconnectedvmware.OsTypeWindows), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // ResourcePoolID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), - // TemplateID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetVirtualMachine.json -func ExampleVirtualMachinesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVirtualMachinesClient().Get(ctx, "testrg", "DemoVM", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.VirtualMachine = armconnectedvmware.VirtualMachine{ - // Name: to.Ptr("DemoVM"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachines/DemoVM"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VirtualMachineProperties{ - // HardwareProfile: &armconnectedvmware.HardwareProfile{ - // MemorySizeMB: to.Ptr[int32](4196), - // NumCPUs: to.Ptr[int32](4), - // }, - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // OSProfile: &armconnectedvmware.OsProfile{ - // ComputerName: to.Ptr("DemoVM"), - // OSType: to.Ptr(armconnectedvmware.OsTypeWindows), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // ResourcePoolID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), - // TemplateID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateVirtualMachine.json -func ExampleVirtualMachinesClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachinesClient().BeginUpdate(ctx, "testrg", "DemoVM", armconnectedvmware.VirtualMachineUpdate{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.VirtualMachine = armconnectedvmware.VirtualMachine{ - // Name: to.Ptr("DemoVM"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachines/DemoVM"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VirtualMachineProperties{ - // HardwareProfile: &armconnectedvmware.HardwareProfile{ - // MemorySizeMB: to.Ptr[int32](4196), - // NumCPUs: to.Ptr[int32](4), - // }, - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // OSProfile: &armconnectedvmware.OsProfile{ - // ComputerName: to.Ptr("DemoVM"), - // OSType: to.Ptr(armconnectedvmware.OsTypeWindows), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // ResourcePoolID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), - // TemplateID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteVirtualMachine.json -func ExampleVirtualMachinesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachinesClient().BeginDelete(ctx, "testrg", "DemoVM", &armconnectedvmware.VirtualMachinesClientBeginDeleteOptions{Force: nil, - Retain: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/StopVirtualMachine.json -func ExampleVirtualMachinesClient_BeginStop() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachinesClient().BeginStop(ctx, "testrg", "DemoVM", &armconnectedvmware.VirtualMachinesClientBeginStopOptions{Body: &armconnectedvmware.StopVirtualMachineOptions{ - SkipShutdown: to.Ptr(true), - }, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/StartVirtualMachine.json -func ExampleVirtualMachinesClient_BeginStart() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachinesClient().BeginStart(ctx, "testrg", "DemoVM", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/RestartVirtualMachine.json -func ExampleVirtualMachinesClient_BeginRestart() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachinesClient().BeginRestart(ctx, "testrg", "DemoVM", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualMachines.json -func ExampleVirtualMachinesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVirtualMachinesClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.VirtualMachinesList = armconnectedvmware.VirtualMachinesList{ - // Value: []*armconnectedvmware.VirtualMachine{ - // { - // Name: to.Ptr("DemoVM"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachines/DemoVM"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VirtualMachineProperties{ - // HardwareProfile: &armconnectedvmware.HardwareProfile{ - // MemorySizeMB: to.Ptr[int32](4196), - // NumCPUs: to.Ptr[int32](4), - // }, - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // OSProfile: &armconnectedvmware.OsProfile{ - // ComputerName: to.Ptr("DemoVM"), - // OSType: to.Ptr(armconnectedvmware.OsTypeWindows), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // ResourcePoolID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), - // TemplateID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualMachinesByResourceGroup.json -func ExampleVirtualMachinesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVirtualMachinesClient().NewListByResourceGroupPager("testrg", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.VirtualMachinesList = armconnectedvmware.VirtualMachinesList{ - // Value: []*armconnectedvmware.VirtualMachine{ - // { - // Name: to.Ptr("DemoVM"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachines"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachines/DemoVM"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VirtualMachineProperties{ - // HardwareProfile: &armconnectedvmware.HardwareProfile{ - // MemorySizeMB: to.Ptr[int32](4196), - // NumCPUs: to.Ptr[int32](4), - // }, - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // OSProfile: &armconnectedvmware.OsProfile{ - // ComputerName: to.Ptr("DemoVM"), - // OSType: to.Ptr(armconnectedvmware.OsTypeWindows), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // ResourcePoolID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool"), - // TemplateID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachinetemplates_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachinetemplates_client.go index 68c3fff50fca..730fa83182a6 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachinetemplates_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachinetemplates_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware @@ -56,7 +56,7 @@ func NewVirtualMachineTemplatesClient(subscriptionID string, credential azcore.T // BeginCreate - Create Or Update virtual machine template. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineTemplateName - Name of the virtual machine template resource. // - body - Request payload. @@ -68,9 +68,10 @@ func (client *VirtualMachineTemplatesClient) BeginCreate(ctx context.Context, re if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineTemplatesClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineTemplatesClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[VirtualMachineTemplatesClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -79,20 +80,22 @@ func (client *VirtualMachineTemplatesClient) BeginCreate(ctx context.Context, re // Create - Create Or Update virtual machine template. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *VirtualMachineTemplatesClient) create(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body VirtualMachineTemplate, options *VirtualMachineTemplatesClientBeginCreateOptions) (*http.Response, error) { + var err error req, err := client.createCreateRequest(ctx, resourceGroupName, virtualMachineTemplateName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createCreateRequest creates the Create request. @@ -115,16 +118,19 @@ func (client *VirtualMachineTemplatesClient) createCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Implements virtual machine template DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineTemplateName - Name of the virtual machine template resource. // - options - VirtualMachineTemplatesClientBeginDeleteOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginDelete @@ -135,7 +141,8 @@ func (client *VirtualMachineTemplatesClient) BeginDelete(ctx context.Context, re if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachineTemplatesClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[VirtualMachineTemplatesClientDeleteResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[VirtualMachineTemplatesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -144,20 +151,22 @@ func (client *VirtualMachineTemplatesClient) BeginDelete(ctx context.Context, re // Delete - Implements virtual machine template DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *VirtualMachineTemplatesClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, options *VirtualMachineTemplatesClientBeginDeleteOptions) (*http.Response, error) { + var err error req, err := client.deleteCreateRequest(ctx, resourceGroupName, virtualMachineTemplateName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -180,7 +189,7 @@ func (client *VirtualMachineTemplatesClient) deleteCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") if options != nil && options.Force != nil { reqQP.Set("force", strconv.FormatBool(*options.Force)) } @@ -192,24 +201,27 @@ func (client *VirtualMachineTemplatesClient) deleteCreateRequest(ctx context.Con // Get - Implements virtual machine template GET method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineTemplateName - Name of the virtual machine template resource. // - options - VirtualMachineTemplatesClientGetOptions contains the optional parameters for the VirtualMachineTemplatesClient.Get // method. func (client *VirtualMachineTemplatesClient) Get(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, options *VirtualMachineTemplatesClientGetOptions) (VirtualMachineTemplatesClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, resourceGroupName, virtualMachineTemplateName, options) if err != nil { return VirtualMachineTemplatesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineTemplatesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return VirtualMachineTemplatesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VirtualMachineTemplatesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -232,7 +244,7 @@ func (client *VirtualMachineTemplatesClient) getCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -249,7 +261,7 @@ func (client *VirtualMachineTemplatesClient) getHandleResponse(resp *http.Respon // NewListPager - List of virtualMachineTemplates in a subscription. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - options - VirtualMachineTemplatesClientListOptions contains the optional parameters for the VirtualMachineTemplatesClient.NewListPager // method. func (client *VirtualMachineTemplatesClient) NewListPager(options *VirtualMachineTemplatesClientListOptions) *runtime.Pager[VirtualMachineTemplatesClientListResponse] { @@ -292,7 +304,7 @@ func (client *VirtualMachineTemplatesClient) listCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -309,7 +321,7 @@ func (client *VirtualMachineTemplatesClient) listHandleResponse(resp *http.Respo // NewListByResourceGroupPager - List of virtualMachineTemplates in a resource group. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - options - VirtualMachineTemplatesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachineTemplatesClient.NewListByResourceGroupPager // method. @@ -357,7 +369,7 @@ func (client *VirtualMachineTemplatesClient) listByResourceGroupCreateRequest(ct return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -375,25 +387,28 @@ func (client *VirtualMachineTemplatesClient) listByResourceGroupHandleResponse(r // Update - API to update certain properties of the virtual machine template resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualMachineTemplateName - Name of the virtual machine template resource. // - body - Resource properties to update. // - options - VirtualMachineTemplatesClientUpdateOptions contains the optional parameters for the VirtualMachineTemplatesClient.Update // method. func (client *VirtualMachineTemplatesClient) Update(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body ResourcePatch, options *VirtualMachineTemplatesClientUpdateOptions) (VirtualMachineTemplatesClientUpdateResponse, error) { + var err error req, err := client.updateCreateRequest(ctx, resourceGroupName, virtualMachineTemplateName, body, options) if err != nil { return VirtualMachineTemplatesClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineTemplatesClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return VirtualMachineTemplatesClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VirtualMachineTemplatesClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -416,10 +431,13 @@ func (client *VirtualMachineTemplatesClient) updateCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // updateHandleResponse handles the Update response. diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachinetemplates_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachinetemplates_client_example_test.go deleted file mode 100644 index a2eb361f92ce..000000000000 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualmachinetemplates_client_example_test.go +++ /dev/null @@ -1,262 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armconnectedvmware_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateVirtualMachineTemplate.json -func ExampleVirtualMachineTemplatesClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachineTemplatesClient().BeginCreate(ctx, "testrg", "WebFrontEndTemplate", armconnectedvmware.VirtualMachineTemplate{ - ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - Type: to.Ptr("customLocation"), - }, - Location: to.Ptr("East US"), - Properties: &armconnectedvmware.VirtualMachineTemplateProperties{ - MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.VirtualMachineTemplate = armconnectedvmware.VirtualMachineTemplate{ - // Name: to.Ptr("WebFrontEndTemplate"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VirtualMachineTemplateProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetVirtualMachineTemplate.json -func ExampleVirtualMachineTemplatesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVirtualMachineTemplatesClient().Get(ctx, "testrg", "WebFrontEndTemplate", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.VirtualMachineTemplate = armconnectedvmware.VirtualMachineTemplate{ - // Name: to.Ptr("WebFrontEndTemplate"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VirtualMachineTemplateProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateVirtualMachineTemplate.json -func ExampleVirtualMachineTemplatesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVirtualMachineTemplatesClient().Update(ctx, "testrg", "WebFrontEndTemplate", armconnectedvmware.ResourcePatch{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.VirtualMachineTemplate = armconnectedvmware.VirtualMachineTemplate{ - // Name: to.Ptr("WebFrontEndTemplate"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VirtualMachineTemplateProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteVirtualMachineTemplate.json -func ExampleVirtualMachineTemplatesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachineTemplatesClient().BeginDelete(ctx, "testrg", "WebFrontEndTemplate", &armconnectedvmware.VirtualMachineTemplatesClientBeginDeleteOptions{Force: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualMachineTemplates.json -func ExampleVirtualMachineTemplatesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVirtualMachineTemplatesClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.VirtualMachineTemplatesList = armconnectedvmware.VirtualMachineTemplatesList{ - // Value: []*armconnectedvmware.VirtualMachineTemplate{ - // { - // Name: to.Ptr("WebFrontEndTemplate"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VirtualMachineTemplateProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualMachineTemplatesByResourceGroup.json -func ExampleVirtualMachineTemplatesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVirtualMachineTemplatesClient().NewListByResourceGroupPager("testrg", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.VirtualMachineTemplatesList = armconnectedvmware.VirtualMachineTemplatesList{ - // Value: []*armconnectedvmware.VirtualMachineTemplate{ - // { - // Name: to.Ptr("WebFrontEndTemplate"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VirtualMachineTemplateProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualnetworks_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualnetworks_client.go index 2a5a458829db..90b6daccfd41 100644 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualnetworks_client.go +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualnetworks_client.go @@ -13,7 +13,7 @@ // 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. -// DO NOT EDIT. +// Code generated by @autorest/go. DO NOT EDIT. package armconnectedvmware @@ -56,7 +56,7 @@ func NewVirtualNetworksClient(subscriptionID string, credential azcore.TokenCred // BeginCreate - Create Or Update virtual network. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualNetworkName - Name of the virtual network resource. // - body - Request payload. @@ -68,9 +68,10 @@ func (client *VirtualNetworksClient) BeginCreate(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualNetworksClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualNetworksClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[VirtualNetworksClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -79,20 +80,22 @@ func (client *VirtualNetworksClient) BeginCreate(ctx context.Context, resourceGr // Create - Create Or Update virtual network. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *VirtualNetworksClient) create(ctx context.Context, resourceGroupName string, virtualNetworkName string, body VirtualNetwork, options *VirtualNetworksClientBeginCreateOptions) (*http.Response, error) { + var err error req, err := client.createCreateRequest(ctx, resourceGroupName, virtualNetworkName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createCreateRequest creates the Create request. @@ -115,16 +118,19 @@ func (client *VirtualNetworksClient) createCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Implements virtual network DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualNetworkName - Name of the virtual network resource. // - options - VirtualNetworksClientBeginDeleteOptions contains the optional parameters for the VirtualNetworksClient.BeginDelete @@ -135,7 +141,8 @@ func (client *VirtualNetworksClient) BeginDelete(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller[VirtualNetworksClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[VirtualNetworksClientDeleteResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[VirtualNetworksClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -144,20 +151,22 @@ func (client *VirtualNetworksClient) BeginDelete(ctx context.Context, resourceGr // Delete - Implements virtual network DELETE method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview func (client *VirtualNetworksClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualNetworkName string, options *VirtualNetworksClientBeginDeleteOptions) (*http.Response, error) { + var err error req, err := client.deleteCreateRequest(ctx, resourceGroupName, virtualNetworkName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -180,7 +189,7 @@ func (client *VirtualNetworksClient) deleteCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") if options != nil && options.Force != nil { reqQP.Set("force", strconv.FormatBool(*options.Force)) } @@ -192,23 +201,26 @@ func (client *VirtualNetworksClient) deleteCreateRequest(ctx context.Context, re // Get - Implements virtual network GET method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualNetworkName - Name of the virtual network resource. // - options - VirtualNetworksClientGetOptions contains the optional parameters for the VirtualNetworksClient.Get method. func (client *VirtualNetworksClient) Get(ctx context.Context, resourceGroupName string, virtualNetworkName string, options *VirtualNetworksClientGetOptions) (VirtualNetworksClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, resourceGroupName, virtualNetworkName, options) if err != nil { return VirtualNetworksClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualNetworksClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return VirtualNetworksClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VirtualNetworksClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -231,7 +243,7 @@ func (client *VirtualNetworksClient) getCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -248,7 +260,7 @@ func (client *VirtualNetworksClient) getHandleResponse(resp *http.Response) (Vir // NewListPager - List of virtualNetworks in a subscription. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - options - VirtualNetworksClientListOptions contains the optional parameters for the VirtualNetworksClient.NewListPager // method. func (client *VirtualNetworksClient) NewListPager(options *VirtualNetworksClientListOptions) *runtime.Pager[VirtualNetworksClientListResponse] { @@ -291,7 +303,7 @@ func (client *VirtualNetworksClient) listCreateRequest(ctx context.Context, opti return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -308,7 +320,7 @@ func (client *VirtualNetworksClient) listHandleResponse(resp *http.Response) (Vi // NewListByResourceGroupPager - List of virtualNetworks in a resource group. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - options - VirtualNetworksClientListByResourceGroupOptions contains the optional parameters for the VirtualNetworksClient.NewListByResourceGroupPager // method. @@ -356,7 +368,7 @@ func (client *VirtualNetworksClient) listByResourceGroupCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -374,24 +386,27 @@ func (client *VirtualNetworksClient) listByResourceGroupHandleResponse(resp *htt // Update - API to update certain properties of the virtual network resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-01-10-preview +// Generated from API version 2023-03-01-preview // - resourceGroupName - The Resource Group Name. // - virtualNetworkName - Name of the virtual network resource. // - body - Resource properties to update. // - options - VirtualNetworksClientUpdateOptions contains the optional parameters for the VirtualNetworksClient.Update method. func (client *VirtualNetworksClient) Update(ctx context.Context, resourceGroupName string, virtualNetworkName string, body ResourcePatch, options *VirtualNetworksClientUpdateOptions) (VirtualNetworksClientUpdateResponse, error) { + var err error req, err := client.updateCreateRequest(ctx, resourceGroupName, virtualNetworkName, body, options) if err != nil { return VirtualNetworksClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualNetworksClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return VirtualNetworksClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VirtualNetworksClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -414,10 +429,13 @@ func (client *VirtualNetworksClient) updateCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-01-10-preview") + reqQP.Set("api-version", "2023-03-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // updateHandleResponse handles the Update response. diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualnetworks_client_example_test.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualnetworks_client_example_test.go deleted file mode 100644 index 0b86165719d3..000000000000 --- a/sdk/resourcemanager/connectedvmware/armconnectedvmware/virtualnetworks_client_example_test.go +++ /dev/null @@ -1,262 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. 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. -// DO NOT EDIT. - -package armconnectedvmware_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/connectedvmware/armconnectedvmware" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/CreateVirtualNetwork.json -func ExampleVirtualNetworksClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualNetworksClient().BeginCreate(ctx, "testrg", "ProdNetwork", armconnectedvmware.VirtualNetwork{ - ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - Type: to.Ptr("customLocation"), - }, - Location: to.Ptr("East US"), - Properties: &armconnectedvmware.VirtualNetworkProperties{ - MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.VirtualNetwork = armconnectedvmware.VirtualNetwork{ - // Name: to.Ptr("ProdNetwork"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualNetworks"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualNetworks/ProdNetwork"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VirtualNetworkProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/GetVirtualNetwork.json -func ExampleVirtualNetworksClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVirtualNetworksClient().Get(ctx, "testrg", "ProdNetwork", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.VirtualNetwork = armconnectedvmware.VirtualNetwork{ - // Name: to.Ptr("ProdNetwork"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualNetworks"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualNetworks/ProdNetwork"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VirtualNetworkProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/UpdateVirtualNetwork.json -func ExampleVirtualNetworksClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVirtualNetworksClient().Update(ctx, "testrg", "ProdNetwork", armconnectedvmware.ResourcePatch{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.VirtualNetwork = armconnectedvmware.VirtualNetwork{ - // Name: to.Ptr("ProdNetwork"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualNetworks"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualNetworks/ProdNetwork"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VirtualNetworkProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // Tags: map[string]*string{ - // "tag1": to.Ptr("value1"), - // "tag2": to.Ptr("value2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/DeleteVirtualNetwork.json -func ExampleVirtualNetworksClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualNetworksClient().BeginDelete(ctx, "testrg", "ProdNetwork", &armconnectedvmware.VirtualNetworksClientBeginDeleteOptions{Force: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualNetworks.json -func ExampleVirtualNetworksClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVirtualNetworksClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.VirtualNetworksList = armconnectedvmware.VirtualNetworksList{ - // Value: []*armconnectedvmware.VirtualNetwork{ - // { - // Name: to.Ptr("ProdNetwork"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualNetworks"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualNetworks/ProdNetwork"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VirtualNetworkProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7473936304533e6716fc4563401bf265dda4cb64/specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/ListVirtualNetworksByResourceGroup.json -func ExampleVirtualNetworksClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconnectedvmware.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVirtualNetworksClient().NewListByResourceGroupPager("testrg", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.VirtualNetworksList = armconnectedvmware.VirtualNetworksList{ - // Value: []*armconnectedvmware.VirtualNetwork{ - // { - // Name: to.Ptr("ProdNetwork"), - // Type: to.Ptr("Microsoft.ConnectedVMwarevSphere/VirtualNetworks"), - // ExtendedLocation: &armconnectedvmware.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualNetworks/ProdNetwork"), - // Location: to.Ptr("East US"), - // Properties: &armconnectedvmware.VirtualNetworkProperties{ - // MoRefID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // ProvisioningState: to.Ptr("Succeeded"), - // VCenterID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/vminstanceguestagents_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/vminstanceguestagents_client.go new file mode 100644 index 000000000000..e0033b371de7 --- /dev/null +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/vminstanceguestagents_client.go @@ -0,0 +1,273 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package armconnectedvmware + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" +) + +// VMInstanceGuestAgentsClient contains the methods for the VMInstanceGuestAgents group. +// Don't use this type directly, use NewVMInstanceGuestAgentsClient() instead. +type VMInstanceGuestAgentsClient struct { + internal *arm.Client +} + +// NewVMInstanceGuestAgentsClient creates a new instance of VMInstanceGuestAgentsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewVMInstanceGuestAgentsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*VMInstanceGuestAgentsClient, error) { + cl, err := arm.NewClient(moduleName+".VMInstanceGuestAgentsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &VMInstanceGuestAgentsClient{ + internal: cl, + } + return client, nil +} + +// BeginCreate - Create Or Update GuestAgent. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. +// - body - Request payload. +// - options - VMInstanceGuestAgentsClientBeginCreateOptions contains the optional parameters for the VMInstanceGuestAgentsClient.BeginCreate +// method. +func (client *VMInstanceGuestAgentsClient) BeginCreate(ctx context.Context, resourceURI string, body GuestAgent, options *VMInstanceGuestAgentsClientBeginCreateOptions) (*runtime.Poller[VMInstanceGuestAgentsClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceURI, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VMInstanceGuestAgentsClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VMInstanceGuestAgentsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Create - Create Or Update GuestAgent. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *VMInstanceGuestAgentsClient) create(ctx context.Context, resourceURI string, body GuestAgent, options *VMInstanceGuestAgentsClientBeginCreateOptions) (*http.Response, error) { + var err error + req, err := client.createCreateRequest(ctx, resourceURI, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCreateRequest creates the Create request. +func (client *VMInstanceGuestAgentsClient) createCreateRequest(ctx context.Context, resourceURI string, body GuestAgent, options *VMInstanceGuestAgentsClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineInstances/default/guestAgents/default" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Implements GuestAgent DELETE method. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. +// - options - VMInstanceGuestAgentsClientBeginDeleteOptions contains the optional parameters for the VMInstanceGuestAgentsClient.BeginDelete +// method. +func (client *VMInstanceGuestAgentsClient) BeginDelete(ctx context.Context, resourceURI string, options *VMInstanceGuestAgentsClientBeginDeleteOptions) (*runtime.Poller[VMInstanceGuestAgentsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceURI, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller[VMInstanceGuestAgentsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VMInstanceGuestAgentsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Implements GuestAgent DELETE method. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +func (client *VMInstanceGuestAgentsClient) deleteOperation(ctx context.Context, resourceURI string, options *VMInstanceGuestAgentsClientBeginDeleteOptions) (*http.Response, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceURI, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *VMInstanceGuestAgentsClient) deleteCreateRequest(ctx context.Context, resourceURI string, options *VMInstanceGuestAgentsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineInstances/default/guestAgents/default" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Implements GuestAgent GET method. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. +// - options - VMInstanceGuestAgentsClientGetOptions contains the optional parameters for the VMInstanceGuestAgentsClient.Get +// method. +func (client *VMInstanceGuestAgentsClient) Get(ctx context.Context, resourceURI string, options *VMInstanceGuestAgentsClientGetOptions) (VMInstanceGuestAgentsClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceURI, options) + if err != nil { + return VMInstanceGuestAgentsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VMInstanceGuestAgentsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VMInstanceGuestAgentsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *VMInstanceGuestAgentsClient) getCreateRequest(ctx context.Context, resourceURI string, options *VMInstanceGuestAgentsClientGetOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineInstances/default/guestAgents/default" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VMInstanceGuestAgentsClient) getHandleResponse(resp *http.Response) (VMInstanceGuestAgentsClientGetResponse, error) { + result := VMInstanceGuestAgentsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GuestAgent); err != nil { + return VMInstanceGuestAgentsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Returns the list of GuestAgent of the given vm. +// +// Generated from API version 2023-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. +// - options - VMInstanceGuestAgentsClientListOptions contains the optional parameters for the VMInstanceGuestAgentsClient.NewListPager +// method. +func (client *VMInstanceGuestAgentsClient) NewListPager(resourceURI string, options *VMInstanceGuestAgentsClientListOptions) *runtime.Pager[VMInstanceGuestAgentsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[VMInstanceGuestAgentsClientListResponse]{ + More: func(page VMInstanceGuestAgentsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VMInstanceGuestAgentsClientListResponse) (VMInstanceGuestAgentsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceURI, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VMInstanceGuestAgentsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VMInstanceGuestAgentsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VMInstanceGuestAgentsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *VMInstanceGuestAgentsClient) listCreateRequest(ctx context.Context, resourceURI string, options *VMInstanceGuestAgentsClientListOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineInstances/default/guestAgents" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *VMInstanceGuestAgentsClient) listHandleResponse(resp *http.Response) (VMInstanceGuestAgentsClientListResponse, error) { + result := VMInstanceGuestAgentsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GuestAgentList); err != nil { + return VMInstanceGuestAgentsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/connectedvmware/armconnectedvmware/vminstancehybrididentitymetadata_client.go b/sdk/resourcemanager/connectedvmware/armconnectedvmware/vminstancehybrididentitymetadata_client.go new file mode 100644 index 000000000000..1a2b446003c1 --- /dev/null +++ b/sdk/resourcemanager/connectedvmware/armconnectedvmware/vminstancehybrididentitymetadata_client.go @@ -0,0 +1,155 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. 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. +// Code generated by @autorest/go. DO NOT EDIT. + +package armconnectedvmware + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" +) + +// VMInstanceHybridIdentityMetadataClient contains the methods for the VMInstanceHybridIdentityMetadata group. +// Don't use this type directly, use NewVMInstanceHybridIdentityMetadataClient() instead. +type VMInstanceHybridIdentityMetadataClient struct { + internal *arm.Client +} + +// NewVMInstanceHybridIdentityMetadataClient creates a new instance of VMInstanceHybridIdentityMetadataClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewVMInstanceHybridIdentityMetadataClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*VMInstanceHybridIdentityMetadataClient, error) { + cl, err := arm.NewClient(moduleName+".VMInstanceHybridIdentityMetadataClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &VMInstanceHybridIdentityMetadataClient{ + internal: cl, + } + return client, nil +} + +// Get - Implements HybridIdentityMetadata GET method. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. +// - options - VMInstanceHybridIdentityMetadataClientGetOptions contains the optional parameters for the VMInstanceHybridIdentityMetadataClient.Get +// method. +func (client *VMInstanceHybridIdentityMetadataClient) Get(ctx context.Context, resourceURI string, options *VMInstanceHybridIdentityMetadataClientGetOptions) (VMInstanceHybridIdentityMetadataClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceURI, options) + if err != nil { + return VMInstanceHybridIdentityMetadataClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VMInstanceHybridIdentityMetadataClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VMInstanceHybridIdentityMetadataClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *VMInstanceHybridIdentityMetadataClient) getCreateRequest(ctx context.Context, resourceURI string, options *VMInstanceHybridIdentityMetadataClientGetOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineInstances/default/hybridIdentityMetadata/default" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VMInstanceHybridIdentityMetadataClient) getHandleResponse(resp *http.Response) (VMInstanceHybridIdentityMetadataClientGetResponse, error) { + result := VMInstanceHybridIdentityMetadataClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VMInstanceHybridIdentityMetadata); err != nil { + return VMInstanceHybridIdentityMetadataClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Returns the list of HybridIdentityMetadata of the given vm. +// +// Generated from API version 2023-03-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. +// - options - VMInstanceHybridIdentityMetadataClientListOptions contains the optional parameters for the VMInstanceHybridIdentityMetadataClient.NewListPager +// method. +func (client *VMInstanceHybridIdentityMetadataClient) NewListPager(resourceURI string, options *VMInstanceHybridIdentityMetadataClientListOptions) *runtime.Pager[VMInstanceHybridIdentityMetadataClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[VMInstanceHybridIdentityMetadataClientListResponse]{ + More: func(page VMInstanceHybridIdentityMetadataClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VMInstanceHybridIdentityMetadataClientListResponse) (VMInstanceHybridIdentityMetadataClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceURI, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VMInstanceHybridIdentityMetadataClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VMInstanceHybridIdentityMetadataClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VMInstanceHybridIdentityMetadataClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *VMInstanceHybridIdentityMetadataClient) listCreateRequest(ctx context.Context, resourceURI string, options *VMInstanceHybridIdentityMetadataClientListOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineInstances/default/hybridIdentityMetadata" + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *VMInstanceHybridIdentityMetadataClient) listHandleResponse(resp *http.Response) (VMInstanceHybridIdentityMetadataClientListResponse, error) { + result := VMInstanceHybridIdentityMetadataClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VMInstanceHybridIdentityMetadataList); err != nil { + return VMInstanceHybridIdentityMetadataClientListResponse{}, err + } + return result, nil +}