From bca1925931989e062b1acb93ae2eec7bb5e0d2ce Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 19 Jun 2024 10:04:01 +0000 Subject: [PATCH] CodeGen from PR 29500 in Azure/azure-rest-api-specs Merge 689e389e4b8d8d6632f98aee4c034d9427ced497 into 89fc547a195b7202ac9731b6dc17596776b12185 --- .../scvmm/armscvmm/CHANGELOG.md | 161 ++ sdk/resourcemanager/scvmm/armscvmm/README.md | 2 +- .../scvmm/armscvmm/autorest.md | 6 +- .../scvmm/armscvmm/availabilitysets_client.go | 144 +- .../availabilitysets_client_example_test.go | 258 --- .../scvmm/armscvmm/client_factory.go | 79 +- .../scvmm/armscvmm/clouds_client.go | 141 +- .../armscvmm/clouds_client_example_test.go | 258 --- .../scvmm/armscvmm/constants.go | 215 ++- .../armscvmm/fake/availabilitysets_server.go | 52 +- .../scvmm/armscvmm/fake/clouds_server.go | 52 +- .../scvmm/armscvmm/fake/guestagents_server.go | 231 +++ .../scvmm/armscvmm/fake/internal.go | 13 +- .../armscvmm/fake/inventoryitems_server.go | 75 +- .../scvmm/armscvmm/fake/server_factory.go | 58 +- .../scvmm/armscvmm/fake/time_rfc3339.go | 42 +- .../fake/virtualmachineinstances_server.go | 618 +++++++ .../armscvmm/fake/virtualmachines_server.go | 731 -------- .../fake/virtualmachinetemplates_server.go | 26 +- .../armscvmm/fake/virtualnetworks_server.go | 26 +- ...minstancehybrididentitymetadatas_server.go | 144 ++ .../scvmm/armscvmm/fake/vmmservers_server.go | 30 +- sdk/resourcemanager/scvmm/armscvmm/go.mod | 12 +- sdk/resourcemanager/scvmm/armscvmm/go.sum | 17 - .../scvmm/armscvmm/guestagents_client.go | 254 +++ .../scvmm/armscvmm/inventoryitems_client.go | 126 +- .../inventoryitems_client_example_test.go | 145 -- sdk/resourcemanager/scvmm/armscvmm/models.go | 938 +++++++---- .../scvmm/armscvmm/models_serde.go | 1486 ++++++++++++----- .../scvmm/armscvmm/operations_client.go | 8 +- .../operations_client_example_test.go | 181 -- sdk/resourcemanager/scvmm/armscvmm/options.go | 170 +- .../scvmm/armscvmm/polymorphic_helpers.go | 2 +- .../{response_types.go => responses.go} | 187 ++- .../scvmm/armscvmm/time_rfc3339.go | 42 +- .../virtualmachineinstances_client.go | 762 +++++++++ .../scvmm/armscvmm/virtualmachines_client.go | 949 ----------- .../virtualmachines_client_example_test.go | 520 ------ .../virtualmachinetemplates_client.go | 85 +- ...ualmachinetemplates_client_example_test.go | 258 --- .../scvmm/armscvmm/virtualnetworks_client.go | 85 +- .../virtualnetworks_client_example_test.go | 258 --- ...minstancehybrididentitymetadatas_client.go | 145 ++ .../scvmm/armscvmm/vmmservers_client.go | 109 +- .../vmmservers_client_example_test.go | 277 --- 45 files changed, 4978 insertions(+), 5400 deletions(-) delete mode 100644 sdk/resourcemanager/scvmm/armscvmm/availabilitysets_client_example_test.go delete mode 100644 sdk/resourcemanager/scvmm/armscvmm/clouds_client_example_test.go create mode 100644 sdk/resourcemanager/scvmm/armscvmm/fake/guestagents_server.go create mode 100644 sdk/resourcemanager/scvmm/armscvmm/fake/virtualmachineinstances_server.go delete mode 100644 sdk/resourcemanager/scvmm/armscvmm/fake/virtualmachines_server.go create mode 100644 sdk/resourcemanager/scvmm/armscvmm/fake/vminstancehybrididentitymetadatas_server.go create mode 100644 sdk/resourcemanager/scvmm/armscvmm/guestagents_client.go delete mode 100644 sdk/resourcemanager/scvmm/armscvmm/inventoryitems_client_example_test.go delete mode 100644 sdk/resourcemanager/scvmm/armscvmm/operations_client_example_test.go rename sdk/resourcemanager/scvmm/armscvmm/{response_types.go => responses.go} (61%) create mode 100644 sdk/resourcemanager/scvmm/armscvmm/virtualmachineinstances_client.go delete mode 100644 sdk/resourcemanager/scvmm/armscvmm/virtualmachines_client.go delete mode 100644 sdk/resourcemanager/scvmm/armscvmm/virtualmachines_client_example_test.go delete mode 100644 sdk/resourcemanager/scvmm/armscvmm/virtualmachinetemplates_client_example_test.go delete mode 100644 sdk/resourcemanager/scvmm/armscvmm/virtualnetworks_client_example_test.go create mode 100644 sdk/resourcemanager/scvmm/armscvmm/vminstancehybrididentitymetadatas_client.go delete mode 100644 sdk/resourcemanager/scvmm/armscvmm/vmmservers_client_example_test.go diff --git a/sdk/resourcemanager/scvmm/armscvmm/CHANGELOG.md b/sdk/resourcemanager/scvmm/armscvmm/CHANGELOG.md index a23f0d560e9f..44bbf24f3222 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/CHANGELOG.md +++ b/sdk/resourcemanager/scvmm/armscvmm/CHANGELOG.md @@ -1,5 +1,166 @@ # Release History +## 1.0.0 (2024-06-19) +### Breaking Changes + +- Function `*AvailabilitySetsClient.BeginUpdate` parameter(s) have been changed from `(context.Context, string, string, ResourcePatch, *AvailabilitySetsClientBeginUpdateOptions)` to `(context.Context, string, string, AvailabilitySetTagsUpdate, *AvailabilitySetsClientBeginUpdateOptions)` +- Function `*CloudsClient.BeginUpdate` parameter(s) have been changed from `(context.Context, string, string, ResourcePatch, *CloudsClientBeginUpdateOptions)` to `(context.Context, string, string, CloudTagsUpdate, *CloudsClientBeginUpdateOptions)` +- Function `*InventoryItemsClient.Create` parameter(s) have been changed from `(context.Context, string, string, string, *InventoryItemsClientCreateOptions)` to `(context.Context, string, string, string, InventoryItem, *InventoryItemsClientCreateOptions)` +- Function `*VirtualMachineTemplatesClient.BeginUpdate` parameter(s) have been changed from `(context.Context, string, string, ResourcePatch, *VirtualMachineTemplatesClientBeginUpdateOptions)` to `(context.Context, string, string, VirtualMachineTemplateTagsUpdate, *VirtualMachineTemplatesClientBeginUpdateOptions)` +- Function `*VirtualNetworksClient.BeginUpdate` parameter(s) have been changed from `(context.Context, string, string, ResourcePatch, *VirtualNetworksClientBeginUpdateOptions)` to `(context.Context, string, string, VirtualNetworkTagsUpdate, *VirtualNetworksClientBeginUpdateOptions)` +- Function `*VmmServersClient.BeginCreateOrUpdate` parameter(s) have been changed from `(context.Context, string, string, VMMServer, *VmmServersClientBeginCreateOrUpdateOptions)` to `(context.Context, string, string, VmmServer, *VmmServersClientBeginCreateOrUpdateOptions)` +- Function `*VmmServersClient.BeginUpdate` parameter(s) have been changed from `(context.Context, string, string, ResourcePatch, *VmmServersClientBeginUpdateOptions)` to `(context.Context, string, string, VmmServerTagsUpdate, *VmmServersClientBeginUpdateOptions)` +- Type of `AvailabilitySetProperties.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `AvailabilitySetsClientBeginDeleteOptions.Force` has been changed from `*bool` to `*ForceDelete` +- Type of `CloudInventoryItem.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `CloudProperties.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `CloudsClientBeginDeleteOptions.Force` has been changed from `*bool` to `*ForceDelete` +- Type of `ErrorResponse.Error` has been changed from `*ErrorDefinition` to `*ErrorDetail` +- Type of `HardwareProfile.IsHighlyAvailable` has been changed from `*string` to `*IsHighlyAvailable` +- Type of `InventoryItemProperties.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `NetworkProfile.NetworkInterfaces` has been changed from `[]*NetworkInterfaces` to `[]*NetworkInterface` +- Type of `NetworkProfileUpdate.NetworkInterfaces` has been changed from `[]*NetworkInterfacesUpdate` to `[]*NetworkInterfaceUpdate` +- Type of `StopVirtualMachineOptions.SkipShutdown` has been changed from `*bool` to `*SkipShutdown` +- Type of `VirtualMachineInventoryItem.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `VirtualMachineTemplateInventoryItem.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `VirtualMachineTemplateProperties.IsHighlyAvailable` has been changed from `*string` to `*IsHighlyAvailable` +- Type of `VirtualMachineTemplateProperties.NetworkInterfaces` has been changed from `[]*NetworkInterfaces` to `[]*NetworkInterface` +- Type of `VirtualMachineTemplateProperties.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `VirtualMachineTemplatesClientBeginDeleteOptions.Force` has been changed from `*bool` to `*ForceDelete` +- Type of `VirtualNetworkInventoryItem.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `VirtualNetworkProperties.ProvisioningState` has been changed from `*string` to `*ProvisioningState` +- Type of `VirtualNetworksClientBeginDeleteOptions.Force` has been changed from `*bool` to `*ForceDelete` +- Type of `VmmServersClientBeginDeleteOptions.Force` has been changed from `*bool` to `*ForceDelete` +- Function `*ClientFactory.NewVirtualMachinesClient` has been removed +- Function `*InventoryItemsClient.NewListByVMMServerPager` has been removed +- Function `NewVirtualMachinesClient` has been removed +- Function `*VirtualMachinesClient.BeginCreateCheckpoint` has been removed +- Function `*VirtualMachinesClient.BeginCreateOrUpdate` has been removed +- Function `*VirtualMachinesClient.BeginDelete` has been removed +- Function `*VirtualMachinesClient.BeginDeleteCheckpoint` has been removed +- Function `*VirtualMachinesClient.Get` has been removed +- Function `*VirtualMachinesClient.NewListByResourceGroupPager` has been removed +- Function `*VirtualMachinesClient.NewListBySubscriptionPager` has been removed +- Function `*VirtualMachinesClient.BeginRestart` has been removed +- Function `*VirtualMachinesClient.BeginRestoreCheckpoint` has been removed +- Function `*VirtualMachinesClient.BeginStart` has been removed +- Function `*VirtualMachinesClient.BeginStop` has been removed +- Function `*VirtualMachinesClient.BeginUpdate` has been removed +- Struct `ErrorDefinition` has been removed +- Struct `InventoryItemsList` has been removed +- Struct `NetworkInterfaces` has been removed +- Struct `NetworkInterfacesUpdate` has been removed +- Struct `OsProfile` has been removed +- Struct `ResourcePatch` has been removed +- Struct `ResourceProviderOperation` has been removed +- Struct `ResourceProviderOperationDisplay` has been removed +- Struct `ResourceProviderOperationList` has been removed +- Struct `StorageQoSPolicy` has been removed +- Struct `StorageQoSPolicyDetails` has been removed +- Struct `VMMServer` has been removed +- Struct `VMMServerListResult` has been removed +- Struct `VMMServerProperties` has been removed +- Struct `VMMServerPropertiesCredentials` has been removed +- Struct `VirtualMachine` has been removed +- Struct `VirtualMachineListResult` has been removed +- Struct `VirtualMachineProperties` has been removed +- Struct `VirtualMachineUpdate` has been removed +- Struct `VirtualMachineUpdateProperties` has been removed +- Field `StorageQoSPolicies` of struct `CloudProperties` has been removed +- Field `Body` of struct `InventoryItemsClientCreateOptions` has been removed +- Field `ResourceProviderOperationList` of struct `OperationsClientListResponse` has been removed +- Field `StorageQoSPolicy` of struct `VirtualDisk` has been removed +- Field `StorageQoSPolicy` of struct `VirtualDiskUpdate` has been removed +- Field `VMMServer` of struct `VmmServersClientCreateOrUpdateResponse` has been removed +- Field `VMMServer` of struct `VmmServersClientGetResponse` has been removed +- Field `VMMServerListResult` of struct `VmmServersClientListByResourceGroupResponse` has been removed +- Field `VMMServerListResult` of struct `VmmServersClientListBySubscriptionResponse` has been removed +- Field `VMMServer` of struct `VmmServersClientUpdateResponse` has been removed + +### Features Added + +- New enum type `ActionType` with values `ActionTypeInternal` +- New enum type `DeleteFromHost` with values `DeleteFromHostFalse`, `DeleteFromHostTrue` +- New enum type `ForceDelete` with values `ForceDeleteFalse`, `ForceDeleteTrue` +- New enum type `IsHighlyAvailable` with values `IsHighlyAvailableFalse`, `IsHighlyAvailableTrue` +- New enum type `Origin` with values `OriginSystem`, `OriginUser`, `OriginUserSystem` +- New enum type `ProvisioningAction` with values `ProvisioningActionInstall`, `ProvisioningActionRepair`, `ProvisioningActionUninstall` +- New enum type `ProvisioningState` with values `ProvisioningStateAccepted`, `ProvisioningStateCanceled`, `ProvisioningStateCreated`, `ProvisioningStateDeleting`, `ProvisioningStateFailed`, `ProvisioningStateProvisioning`, `ProvisioningStateSucceeded`, `ProvisioningStateUpdating` +- New enum type `SkipShutdown` with values `SkipShutdownFalse`, `SkipShutdownTrue` +- New function `*ClientFactory.NewGuestAgentsClient() *GuestAgentsClient` +- New function `*ClientFactory.NewVMInstanceHybridIdentityMetadatasClient() *VMInstanceHybridIdentityMetadatasClient` +- New function `*ClientFactory.NewVirtualMachineInstancesClient() *VirtualMachineInstancesClient` +- New function `NewGuestAgentsClient(azcore.TokenCredential, *arm.ClientOptions) (*GuestAgentsClient, error)` +- New function `*GuestAgentsClient.BeginCreate(context.Context, string, GuestAgent, *GuestAgentsClientBeginCreateOptions) (*runtime.Poller[GuestAgentsClientCreateResponse], error)` +- New function `*GuestAgentsClient.Delete(context.Context, string, *GuestAgentsClientDeleteOptions) (GuestAgentsClientDeleteResponse, error)` +- New function `*GuestAgentsClient.Get(context.Context, string, *GuestAgentsClientGetOptions) (GuestAgentsClientGetResponse, error)` +- New function `*GuestAgentsClient.NewListByVirtualMachineInstancePager(string, *GuestAgentsClientListByVirtualMachineInstanceOptions) *runtime.Pager[GuestAgentsClientListByVirtualMachineInstanceResponse]` +- New function `*InventoryItemsClient.NewListByVmmServerPager(string, string, *InventoryItemsClientListByVmmServerOptions) *runtime.Pager[InventoryItemsClientListByVmmServerResponse]` +- New function `NewVMInstanceHybridIdentityMetadatasClient(azcore.TokenCredential, *arm.ClientOptions) (*VMInstanceHybridIdentityMetadatasClient, error)` +- New function `*VMInstanceHybridIdentityMetadatasClient.Get(context.Context, string, *VMInstanceHybridIdentityMetadatasClientGetOptions) (VMInstanceHybridIdentityMetadatasClientGetResponse, error)` +- New function `*VMInstanceHybridIdentityMetadatasClient.NewListByVirtualMachineInstancePager(string, *VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceOptions) *runtime.Pager[VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceResponse]` +- New function `NewVirtualMachineInstancesClient(azcore.TokenCredential, *arm.ClientOptions) (*VirtualMachineInstancesClient, error)` +- New function `*VirtualMachineInstancesClient.BeginCreateCheckpoint(context.Context, string, VirtualMachineCreateCheckpoint, *VirtualMachineInstancesClientBeginCreateCheckpointOptions) (*runtime.Poller[VirtualMachineInstancesClientCreateCheckpointResponse], 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.BeginDeleteCheckpoint(context.Context, string, VirtualMachineDeleteCheckpoint, *VirtualMachineInstancesClientBeginDeleteCheckpointOptions) (*runtime.Poller[VirtualMachineInstancesClientDeleteCheckpointResponse], 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.BeginRestoreCheckpoint(context.Context, string, VirtualMachineRestoreCheckpoint, *VirtualMachineInstancesClientBeginRestoreCheckpointOptions) (*runtime.Poller[VirtualMachineInstancesClientRestoreCheckpointResponse], error)` +- New function `*VirtualMachineInstancesClient.BeginStart(context.Context, string, *VirtualMachineInstancesClientBeginStartOptions) (*runtime.Poller[VirtualMachineInstancesClientStartResponse], error)` +- New function `*VirtualMachineInstancesClient.BeginStop(context.Context, string, StopVirtualMachineOptions, *VirtualMachineInstancesClientBeginStopOptions) (*runtime.Poller[VirtualMachineInstancesClientStopResponse], error)` +- New function `*VirtualMachineInstancesClient.BeginUpdate(context.Context, string, VirtualMachineInstanceUpdate, *VirtualMachineInstancesClientBeginUpdateOptions) (*runtime.Poller[VirtualMachineInstancesClientUpdateResponse], error)` +- New struct `AvailabilitySetTagsUpdate` +- New struct `CloudTagsUpdate` +- New struct `ErrorAdditionalInfo` +- New struct `ErrorDetail` +- New struct `GuestAgent` +- New struct `GuestAgentListResult` +- New struct `GuestAgentProperties` +- New struct `GuestCredential` +- New struct `HTTPProxyConfiguration` +- New struct `InfrastructureProfile` +- New struct `InfrastructureProfileUpdate` +- New struct `InventoryItemListResult` +- New struct `NetworkInterface` +- New struct `NetworkInterfaceUpdate` +- New struct `Operation` +- New struct `OperationDisplay` +- New struct `OperationListResult` +- New struct `OsProfileForVMInstance` +- New struct `StorageQosPolicy` +- New struct `StorageQosPolicyDetails` +- New struct `TrackedResource` +- New struct `VMInstanceHybridIdentityMetadata` +- New struct `VMInstanceHybridIdentityMetadataListResult` +- New struct `VMInstanceHybridIdentityMetadataProperties` +- New struct `VirtualMachineInstance` +- New struct `VirtualMachineInstanceListResult` +- New struct `VirtualMachineInstanceProperties` +- New struct `VirtualMachineInstanceUpdate` +- New struct `VirtualMachineInstanceUpdateProperties` +- New struct `VirtualMachineTemplateTagsUpdate` +- New struct `VirtualNetworkTagsUpdate` +- New struct `VmmCredential` +- New struct `VmmServer` +- New struct `VmmServerListResult` +- New struct `VmmServerProperties` +- New struct `VmmServerTagsUpdate` +- New field `StorageQosPolicies` in struct `CloudProperties` +- New anonymous field `OperationListResult` in struct `OperationsClientListResponse` +- New field `SystemData` in struct `ProxyResource` +- New field `SystemData` in struct `Resource` +- New field `StorageQosPolicy` in struct `VirtualDisk` +- New field `StorageQosPolicy` in struct `VirtualDiskUpdate` +- New field `BiosGUID`, `ManagedMachineResourceID`, `OSVersion` in struct `VirtualMachineInventoryItem` +- New anonymous field `VmmServer` in struct `VmmServersClientCreateOrUpdateResponse` +- New anonymous field `VmmServer` in struct `VmmServersClientGetResponse` +- New anonymous field `VmmServerListResult` in struct `VmmServersClientListByResourceGroupResponse` +- New anonymous field `VmmServerListResult` in struct `VmmServersClientListBySubscriptionResponse` +- New anonymous field `VmmServer` in struct `VmmServersClientUpdateResponse` + + ## 0.4.0 (2023-11-30) ### Features Added diff --git a/sdk/resourcemanager/scvmm/armscvmm/README.md b/sdk/resourcemanager/scvmm/armscvmm/README.md index c3b25b63b852..8de88d0e8735 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/README.md +++ b/sdk/resourcemanager/scvmm/armscvmm/README.md @@ -57,7 +57,7 @@ clientFactory, err := armscvmm.NewClientFactory(, cred, &option A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. ```go -client := clientFactory.NewCloudsClient() +client := clientFactory.NewAvailabilitySetsClient() ``` ## Fakes diff --git a/sdk/resourcemanager/scvmm/armscvmm/autorest.md b/sdk/resourcemanager/scvmm/armscvmm/autorest.md index cda981412b24..55005a84bab4 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/autorest.md +++ b/sdk/resourcemanager/scvmm/armscvmm/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/scvmm/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/scvmm/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.4.0 +module-version: 1.0.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/scvmm/armscvmm/availabilitysets_client.go b/sdk/resourcemanager/scvmm/armscvmm/availabilitysets_client.go index 445c73907afb..b593e3a91dcd 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/availabilitysets_client.go +++ b/sdk/resourcemanager/scvmm/armscvmm/availabilitysets_client.go @@ -17,7 +17,6 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" - "strconv" "strings" ) @@ -29,7 +28,7 @@ type AvailabilitySetsClient struct { } // NewAvailabilitySetsClient creates a new instance of AvailabilitySetsClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewAvailabilitySetsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AvailabilitySetsClient, error) { @@ -47,15 +46,15 @@ func NewAvailabilitySetsClient(subscriptionID string, credential azcore.TokenCre // BeginCreateOrUpdate - Onboards the ScVmm availability set as an Azure resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - availabilitySetName - Name of the AvailabilitySet. -// - body - Request payload. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - availabilitySetResourceName - Name of the AvailabilitySet. +// - resource - Resource create parameters. // - options - AvailabilitySetsClientBeginCreateOrUpdateOptions contains the optional parameters for the AvailabilitySetsClient.BeginCreateOrUpdate // method. -func (client *AvailabilitySetsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, availabilitySetName string, body AvailabilitySet, options *AvailabilitySetsClientBeginCreateOrUpdateOptions) (*runtime.Poller[AvailabilitySetsClientCreateOrUpdateResponse], error) { +func (client *AvailabilitySetsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, availabilitySetResourceName string, resource AvailabilitySet, options *AvailabilitySetsClientBeginCreateOrUpdateOptions) (*runtime.Poller[AvailabilitySetsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.createOrUpdate(ctx, resourceGroupName, availabilitySetName, body, options) + resp, err := client.createOrUpdate(ctx, resourceGroupName, availabilitySetResourceName, resource, options) if err != nil { return nil, err } @@ -74,14 +73,14 @@ func (client *AvailabilitySetsClient) BeginCreateOrUpdate(ctx context.Context, r // CreateOrUpdate - Onboards the ScVmm availability set as an Azure resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -func (client *AvailabilitySetsClient) createOrUpdate(ctx context.Context, resourceGroupName string, availabilitySetName string, body AvailabilitySet, options *AvailabilitySetsClientBeginCreateOrUpdateOptions) (*http.Response, error) { +// Generated from API version 2024-06-01 +func (client *AvailabilitySetsClient) createOrUpdate(ctx context.Context, resourceGroupName string, availabilitySetResourceName string, resource AvailabilitySet, options *AvailabilitySetsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "AvailabilitySetsClient.BeginCreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, availabilitySetName, body, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, availabilitySetResourceName, resource, options) if err != nil { return nil, err } @@ -97,8 +96,8 @@ func (client *AvailabilitySetsClient) createOrUpdate(ctx context.Context, resour } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *AvailabilitySetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetName string, body AvailabilitySet, options *AvailabilitySetsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}" +func (client *AvailabilitySetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetResourceName string, resource AvailabilitySet, options *AvailabilitySetsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetResourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -107,19 +106,19 @@ func (client *AvailabilitySetsClient) createOrUpdateCreateRequest(ctx context.Co return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if availabilitySetName == "" { - return nil, errors.New("parameter availabilitySetName cannot be empty") + if availabilitySetResourceName == "" { + return nil, errors.New("parameter availabilitySetResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{availabilitySetName}", url.PathEscape(availabilitySetName)) + urlPath = strings.ReplaceAll(urlPath, "{availabilitySetResourceName}", url.PathEscape(availabilitySetResourceName)) 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", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, body); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil @@ -128,19 +127,20 @@ func (client *AvailabilitySetsClient) createOrUpdateCreateRequest(ctx context.Co // BeginDelete - Deregisters the ScVmm availability set from Azure. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - availabilitySetName - Name of the AvailabilitySet. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - availabilitySetResourceName - Name of the AvailabilitySet. // - options - AvailabilitySetsClientBeginDeleteOptions contains the optional parameters for the AvailabilitySetsClient.BeginDelete // method. -func (client *AvailabilitySetsClient) BeginDelete(ctx context.Context, resourceGroupName string, availabilitySetName string, options *AvailabilitySetsClientBeginDeleteOptions) (*runtime.Poller[AvailabilitySetsClientDeleteResponse], error) { +func (client *AvailabilitySetsClient) BeginDelete(ctx context.Context, resourceGroupName string, availabilitySetResourceName string, options *AvailabilitySetsClientBeginDeleteOptions) (*runtime.Poller[AvailabilitySetsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.deleteOperation(ctx, resourceGroupName, availabilitySetName, options) + resp, err := client.deleteOperation(ctx, resourceGroupName, availabilitySetResourceName, options) if err != nil { return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AvailabilitySetsClientDeleteResponse]{ - Tracer: client.internal.Tracer(), + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) return poller, err } else { @@ -153,14 +153,14 @@ func (client *AvailabilitySetsClient) BeginDelete(ctx context.Context, resourceG // Delete - Deregisters the ScVmm availability set from Azure. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -func (client *AvailabilitySetsClient) deleteOperation(ctx context.Context, resourceGroupName string, availabilitySetName string, options *AvailabilitySetsClientBeginDeleteOptions) (*http.Response, error) { +// Generated from API version 2024-06-01 +func (client *AvailabilitySetsClient) deleteOperation(ctx context.Context, resourceGroupName string, availabilitySetResourceName string, options *AvailabilitySetsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "AvailabilitySetsClient.BeginDelete" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.deleteCreateRequest(ctx, resourceGroupName, availabilitySetName, options) + req, err := client.deleteCreateRequest(ctx, resourceGroupName, availabilitySetResourceName, options) if err != nil { return nil, err } @@ -168,7 +168,7 @@ func (client *AvailabilitySetsClient) deleteOperation(ctx context.Context, resou if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -176,8 +176,8 @@ func (client *AvailabilitySetsClient) deleteOperation(ctx context.Context, resou } // deleteCreateRequest creates the Delete request. -func (client *AvailabilitySetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetName string, options *AvailabilitySetsClientBeginDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}" +func (client *AvailabilitySetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetResourceName string, options *AvailabilitySetsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetResourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -186,18 +186,18 @@ func (client *AvailabilitySetsClient) deleteCreateRequest(ctx context.Context, r return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if availabilitySetName == "" { - return nil, errors.New("parameter availabilitySetName cannot be empty") + if availabilitySetResourceName == "" { + return nil, errors.New("parameter availabilitySetResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{availabilitySetName}", url.PathEscape(availabilitySetName)) + urlPath = strings.ReplaceAll(urlPath, "{availabilitySetResourceName}", url.PathEscape(availabilitySetResourceName)) 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", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") if options != nil && options.Force != nil { - reqQP.Set("force", strconv.FormatBool(*options.Force)) + reqQP.Set("force", string(*options.Force)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} @@ -207,17 +207,17 @@ func (client *AvailabilitySetsClient) deleteCreateRequest(ctx context.Context, r // Get - Implements AvailabilitySet GET method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - availabilitySetName - Name of the AvailabilitySet. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - availabilitySetResourceName - Name of the AvailabilitySet. // - options - AvailabilitySetsClientGetOptions contains the optional parameters for the AvailabilitySetsClient.Get method. -func (client *AvailabilitySetsClient) Get(ctx context.Context, resourceGroupName string, availabilitySetName string, options *AvailabilitySetsClientGetOptions) (AvailabilitySetsClientGetResponse, error) { +func (client *AvailabilitySetsClient) Get(ctx context.Context, resourceGroupName string, availabilitySetResourceName string, options *AvailabilitySetsClientGetOptions) (AvailabilitySetsClientGetResponse, error) { var err error const operationName = "AvailabilitySetsClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, resourceGroupName, availabilitySetName, options) + req, err := client.getCreateRequest(ctx, resourceGroupName, availabilitySetResourceName, options) if err != nil { return AvailabilitySetsClientGetResponse{}, err } @@ -234,8 +234,8 @@ func (client *AvailabilitySetsClient) Get(ctx context.Context, resourceGroupName } // getCreateRequest creates the Get request. -func (client *AvailabilitySetsClient) getCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetName string, options *AvailabilitySetsClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}" +func (client *AvailabilitySetsClient) getCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetResourceName string, options *AvailabilitySetsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetResourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -244,16 +244,16 @@ func (client *AvailabilitySetsClient) getCreateRequest(ctx context.Context, reso return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if availabilitySetName == "" { - return nil, errors.New("parameter availabilitySetName cannot be empty") + if availabilitySetResourceName == "" { + return nil, errors.New("parameter availabilitySetResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{availabilitySetName}", url.PathEscape(availabilitySetName)) + urlPath = strings.ReplaceAll(urlPath, "{availabilitySetResourceName}", url.PathEscape(availabilitySetResourceName)) 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", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -270,8 +270,8 @@ func (client *AvailabilitySetsClient) getHandleResponse(resp *http.Response) (Av // NewListByResourceGroupPager - List of AvailabilitySets in a resource group. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - AvailabilitySetsClientListByResourceGroupOptions contains the optional parameters for the AvailabilitySetsClient.NewListByResourceGroupPager // method. func (client *AvailabilitySetsClient) NewListByResourceGroupPager(resourceGroupName string, options *AvailabilitySetsClientListByResourceGroupOptions) *runtime.Pager[AvailabilitySetsClientListByResourceGroupResponse] { @@ -313,7 +313,7 @@ func (client *AvailabilitySetsClient) listByResourceGroupCreateRequest(ctx conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -330,7 +330,7 @@ func (client *AvailabilitySetsClient) listByResourceGroupHandleResponse(resp *ht // NewListBySubscriptionPager - List of AvailabilitySets in a subscription. // -// Generated from API version 2020-06-05-preview +// Generated from API version 2024-06-01 // - options - AvailabilitySetsClientListBySubscriptionOptions contains the optional parameters for the AvailabilitySetsClient.NewListBySubscriptionPager // method. func (client *AvailabilitySetsClient) NewListBySubscriptionPager(options *AvailabilitySetsClientListBySubscriptionOptions) *runtime.Pager[AvailabilitySetsClientListBySubscriptionResponse] { @@ -368,7 +368,7 @@ func (client *AvailabilitySetsClient) listBySubscriptionCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -386,15 +386,15 @@ func (client *AvailabilitySetsClient) listBySubscriptionHandleResponse(resp *htt // BeginUpdate - Updates the AvailabilitySets resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - availabilitySetName - Name of the AvailabilitySet. -// - body - AvailabilitySets patch payload. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - availabilitySetResourceName - Name of the AvailabilitySet. +// - properties - The resource properties to be updated. // - options - AvailabilitySetsClientBeginUpdateOptions contains the optional parameters for the AvailabilitySetsClient.BeginUpdate // method. -func (client *AvailabilitySetsClient) BeginUpdate(ctx context.Context, resourceGroupName string, availabilitySetName string, body ResourcePatch, options *AvailabilitySetsClientBeginUpdateOptions) (*runtime.Poller[AvailabilitySetsClientUpdateResponse], error) { +func (client *AvailabilitySetsClient) BeginUpdate(ctx context.Context, resourceGroupName string, availabilitySetResourceName string, properties AvailabilitySetTagsUpdate, options *AvailabilitySetsClientBeginUpdateOptions) (*runtime.Poller[AvailabilitySetsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.update(ctx, resourceGroupName, availabilitySetName, body, options) + resp, err := client.update(ctx, resourceGroupName, availabilitySetResourceName, properties, options) if err != nil { return nil, err } @@ -413,14 +413,14 @@ func (client *AvailabilitySetsClient) BeginUpdate(ctx context.Context, resourceG // Update - Updates the AvailabilitySets resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -func (client *AvailabilitySetsClient) update(ctx context.Context, resourceGroupName string, availabilitySetName string, body ResourcePatch, options *AvailabilitySetsClientBeginUpdateOptions) (*http.Response, error) { +// Generated from API version 2024-06-01 +func (client *AvailabilitySetsClient) update(ctx context.Context, resourceGroupName string, availabilitySetResourceName string, properties AvailabilitySetTagsUpdate, options *AvailabilitySetsClientBeginUpdateOptions) (*http.Response, error) { var err error const operationName = "AvailabilitySetsClient.BeginUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, resourceGroupName, availabilitySetName, body, options) + req, err := client.updateCreateRequest(ctx, resourceGroupName, availabilitySetResourceName, properties, options) if err != nil { return nil, err } @@ -428,7 +428,7 @@ func (client *AvailabilitySetsClient) update(ctx context.Context, resourceGroupN if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -436,29 +436,29 @@ func (client *AvailabilitySetsClient) update(ctx context.Context, resourceGroupN } // updateCreateRequest creates the Update request. -func (client *AvailabilitySetsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetName string, body ResourcePatch, options *AvailabilitySetsClientBeginUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) +func (client *AvailabilitySetsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetResourceName string, properties AvailabilitySetTagsUpdate, options *AvailabilitySetsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/availabilitySets/{availabilitySetResourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if availabilitySetName == "" { - return nil, errors.New("parameter availabilitySetName cannot be empty") + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if availabilitySetResourceName == "" { + return nil, errors.New("parameter availabilitySetResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{availabilitySetName}", url.PathEscape(availabilitySetName)) + urlPath = strings.ReplaceAll(urlPath, "{availabilitySetResourceName}", url.PathEscape(availabilitySetResourceName)) 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", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, body); err != nil { + if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } return req, nil diff --git a/sdk/resourcemanager/scvmm/armscvmm/availabilitysets_client_example_test.go b/sdk/resourcemanager/scvmm/armscvmm/availabilitysets_client_example_test.go deleted file mode 100644 index 68df65d86fe5..000000000000 --- a/sdk/resourcemanager/scvmm/armscvmm/availabilitysets_client_example_test.go +++ /dev/null @@ -1,258 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// 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 armscvmm_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/scvmm/armscvmm" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/GetAvailabilitySet.json -func ExampleAvailabilitySetsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAvailabilitySetsClient().Get(ctx, "testrg", "HRAvailabilitySet", 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.AvailabilitySet = armscvmm.AvailabilitySet{ - // Name: to.Ptr("HRAvailabilitySet"), - // Type: to.Ptr("Microsoft.ScVmm/AvailabilitySets"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ScVmm/AvailabilitySets/HRAvailabilitySet"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.AvailabilitySetProperties{ - // AvailabilitySetName: to.Ptr("hr-avset"), - // ProvisioningState: to.Ptr("Succeeded"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ScVmm/VMMServers/ContosoVMMServer"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/CreateAvailabilitySet.json -func ExampleAvailabilitySetsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAvailabilitySetsClient().BeginCreateOrUpdate(ctx, "testrg", "HRAvailabilitySet", armscvmm.AvailabilitySet{ - ExtendedLocation: &armscvmm.ExtendedLocation{ - Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - Type: to.Ptr("customLocation"), - }, - Location: to.Ptr("East US"), - Properties: &armscvmm.AvailabilitySetProperties{ - AvailabilitySetName: to.Ptr("hr-avset"), - VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ScVmm/VMMServers/ContosoVMMServer"), - }, - }, 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.AvailabilitySet = armscvmm.AvailabilitySet{ - // Name: to.Ptr("HRAvailabilitySet"), - // Type: to.Ptr("Microsoft.ScVmm/AvailabilitySets"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ScVmm/AvailabilitySets/HRAvailabilitySet"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.AvailabilitySetProperties{ - // AvailabilitySetName: to.Ptr("hr-avset"), - // ProvisioningState: to.Ptr("Succeeded"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ScVmm/VMMServers/ContosoVMMServer"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/DeleteAvailabilitySet.json -func ExampleAvailabilitySetsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAvailabilitySetsClient().BeginDelete(ctx, "testrg", "HRAvailabilitySet", &armscvmm.AvailabilitySetsClientBeginDeleteOptions{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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/UpdateAvailabilitySet.json -func ExampleAvailabilitySetsClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAvailabilitySetsClient().BeginUpdate(ctx, "testrg", "HRAvailabilitySet", armscvmm.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) - } - 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.AvailabilitySet = armscvmm.AvailabilitySet{ - // Name: to.Ptr("HRAvailabilitySet"), - // Type: to.Ptr("Microsoft.ScVmm/AvailabilitySets"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ScVmm/AvailabilitySets/HRAvailabilitySet"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.AvailabilitySetProperties{ - // AvailabilitySetName: to.Ptr("hr-avset"), - // ProvisioningState: to.Ptr("Succeeded"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ScVmm/VMMServers/ContosoVMMServer"), - // }, - // 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListAvailabilitySetsByResourceGroup.json -func ExampleAvailabilitySetsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAvailabilitySetsClient().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.AvailabilitySetListResult = armscvmm.AvailabilitySetListResult{ - // Value: []*armscvmm.AvailabilitySet{ - // { - // Name: to.Ptr("HRAvailabilitySet"), - // Type: to.Ptr("Microsoft.ScVmm/AvailabilitySets"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ScVmm/AvailabilitySets/HRAvailabilitySet"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.AvailabilitySetProperties{ - // AvailabilitySetName: to.Ptr("hr-avset"), - // ProvisioningState: to.Ptr("Succeeded"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ScVmm/VMMServers/ContosoVMMServer"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListAvailabilitySetsBySubscription.json -func ExampleAvailabilitySetsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAvailabilitySetsClient().NewListBySubscriptionPager(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.AvailabilitySetListResult = armscvmm.AvailabilitySetListResult{ - // Value: []*armscvmm.AvailabilitySet{ - // { - // Name: to.Ptr("HRAvailabilitySet"), - // Type: to.Ptr("Microsoft.ScVmm/AvailabilitySets"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ScVmm/AvailabilitySets/HRAvailabilitySet"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.AvailabilitySetProperties{ - // AvailabilitySetName: to.Ptr("hr-avset"), - // ProvisioningState: to.Ptr("Succeeded"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ScVmm/VMMServers/ContosoVMMServer"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/scvmm/armscvmm/client_factory.go b/sdk/resourcemanager/scvmm/armscvmm/client_factory.go index 1bfc3ebde3ee..09d6b51885d0 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/client_factory.go +++ b/sdk/resourcemanager/scvmm/armscvmm/client_factory.go @@ -17,70 +17,97 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { - _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } // NewAvailabilitySetsClient creates a new instance of AvailabilitySetsClient. func (c *ClientFactory) NewAvailabilitySetsClient() *AvailabilitySetsClient { - subClient, _ := NewAvailabilitySetsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &AvailabilitySetsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewCloudsClient creates a new instance of CloudsClient. func (c *ClientFactory) NewCloudsClient() *CloudsClient { - subClient, _ := NewCloudsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &CloudsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewGuestAgentsClient creates a new instance of GuestAgentsClient. +func (c *ClientFactory) NewGuestAgentsClient() *GuestAgentsClient { + return &GuestAgentsClient{ + internal: c.internal, + } } // NewInventoryItemsClient creates a new instance of InventoryItemsClient. func (c *ClientFactory) NewInventoryItemsClient() *InventoryItemsClient { - subClient, _ := NewInventoryItemsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &InventoryItemsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient + return &OperationsClient{ + internal: c.internal, + } } -// NewVirtualMachineTemplatesClient creates a new instance of VirtualMachineTemplatesClient. -func (c *ClientFactory) NewVirtualMachineTemplatesClient() *VirtualMachineTemplatesClient { - subClient, _ := NewVirtualMachineTemplatesClient(c.subscriptionID, c.credential, c.options) - return subClient +// NewVMInstanceHybridIdentityMetadatasClient creates a new instance of VMInstanceHybridIdentityMetadatasClient. +func (c *ClientFactory) NewVMInstanceHybridIdentityMetadatasClient() *VMInstanceHybridIdentityMetadatasClient { + return &VMInstanceHybridIdentityMetadatasClient{ + internal: c.internal, + } } -// NewVirtualMachinesClient creates a new instance of VirtualMachinesClient. -func (c *ClientFactory) NewVirtualMachinesClient() *VirtualMachinesClient { - subClient, _ := NewVirtualMachinesClient(c.subscriptionID, c.credential, c.options) - return subClient +// NewVirtualMachineInstancesClient creates a new instance of VirtualMachineInstancesClient. +func (c *ClientFactory) NewVirtualMachineInstancesClient() *VirtualMachineInstancesClient { + return &VirtualMachineInstancesClient{ + internal: c.internal, + } +} + +// NewVirtualMachineTemplatesClient creates a new instance of VirtualMachineTemplatesClient. +func (c *ClientFactory) NewVirtualMachineTemplatesClient() *VirtualMachineTemplatesClient { + return &VirtualMachineTemplatesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewVirtualNetworksClient creates a new instance of VirtualNetworksClient. func (c *ClientFactory) NewVirtualNetworksClient() *VirtualNetworksClient { - subClient, _ := NewVirtualNetworksClient(c.subscriptionID, c.credential, c.options) - return subClient + return &VirtualNetworksClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewVmmServersClient creates a new instance of VmmServersClient. func (c *ClientFactory) NewVmmServersClient() *VmmServersClient { - subClient, _ := NewVmmServersClient(c.subscriptionID, c.credential, c.options) - return subClient + return &VmmServersClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/scvmm/armscvmm/clouds_client.go b/sdk/resourcemanager/scvmm/armscvmm/clouds_client.go index b61a9113b474..5f2de325e9bd 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/clouds_client.go +++ b/sdk/resourcemanager/scvmm/armscvmm/clouds_client.go @@ -17,7 +17,6 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" - "strconv" "strings" ) @@ -29,7 +28,7 @@ type CloudsClient struct { } // NewCloudsClient creates a new instance of CloudsClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewCloudsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CloudsClient, error) { @@ -47,15 +46,15 @@ func NewCloudsClient(subscriptionID string, credential azcore.TokenCredential, o // BeginCreateOrUpdate - Onboards the ScVmm fabric cloud as an Azure cloud resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - cloudName - Name of the Cloud. -// - body - Request payload. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - cloudResourceName - Name of the Cloud. +// - resource - Resource create parameters. // - options - CloudsClientBeginCreateOrUpdateOptions contains the optional parameters for the CloudsClient.BeginCreateOrUpdate // method. -func (client *CloudsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, cloudName string, body Cloud, options *CloudsClientBeginCreateOrUpdateOptions) (*runtime.Poller[CloudsClientCreateOrUpdateResponse], error) { +func (client *CloudsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, cloudResourceName string, resource Cloud, options *CloudsClientBeginCreateOrUpdateOptions) (*runtime.Poller[CloudsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.createOrUpdate(ctx, resourceGroupName, cloudName, body, options) + resp, err := client.createOrUpdate(ctx, resourceGroupName, cloudResourceName, resource, options) if err != nil { return nil, err } @@ -74,14 +73,14 @@ func (client *CloudsClient) BeginCreateOrUpdate(ctx context.Context, resourceGro // CreateOrUpdate - Onboards the ScVmm fabric cloud as an Azure cloud resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -func (client *CloudsClient) createOrUpdate(ctx context.Context, resourceGroupName string, cloudName string, body Cloud, options *CloudsClientBeginCreateOrUpdateOptions) (*http.Response, error) { +// Generated from API version 2024-06-01 +func (client *CloudsClient) createOrUpdate(ctx context.Context, resourceGroupName string, cloudResourceName string, resource Cloud, options *CloudsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "CloudsClient.BeginCreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, cloudName, body, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, cloudResourceName, resource, options) if err != nil { return nil, err } @@ -97,8 +96,8 @@ func (client *CloudsClient) createOrUpdate(ctx context.Context, resourceGroupNam } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *CloudsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, cloudName string, body Cloud, options *CloudsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}" +func (client *CloudsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, cloudResourceName string, resource Cloud, options *CloudsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudResourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -107,19 +106,19 @@ func (client *CloudsClient) createOrUpdateCreateRequest(ctx context.Context, res return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if cloudName == "" { - return nil, errors.New("parameter cloudName cannot be empty") + if cloudResourceName == "" { + return nil, errors.New("parameter cloudResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{cloudName}", url.PathEscape(cloudName)) + urlPath = strings.ReplaceAll(urlPath, "{cloudResourceName}", url.PathEscape(cloudResourceName)) 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", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, body); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil @@ -128,13 +127,13 @@ func (client *CloudsClient) createOrUpdateCreateRequest(ctx context.Context, res // BeginDelete - Deregisters the ScVmm fabric cloud from Azure. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - cloudName - Name of the Cloud. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - cloudResourceName - Name of the Cloud. // - options - CloudsClientBeginDeleteOptions contains the optional parameters for the CloudsClient.BeginDelete method. -func (client *CloudsClient) BeginDelete(ctx context.Context, resourceGroupName string, cloudName string, options *CloudsClientBeginDeleteOptions) (*runtime.Poller[CloudsClientDeleteResponse], error) { +func (client *CloudsClient) BeginDelete(ctx context.Context, resourceGroupName string, cloudResourceName string, options *CloudsClientBeginDeleteOptions) (*runtime.Poller[CloudsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.deleteOperation(ctx, resourceGroupName, cloudName, options) + resp, err := client.deleteOperation(ctx, resourceGroupName, cloudResourceName, options) if err != nil { return nil, err } @@ -153,14 +152,14 @@ func (client *CloudsClient) BeginDelete(ctx context.Context, resourceGroupName s // Delete - Deregisters the ScVmm fabric cloud from Azure. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -func (client *CloudsClient) deleteOperation(ctx context.Context, resourceGroupName string, cloudName string, options *CloudsClientBeginDeleteOptions) (*http.Response, error) { +// Generated from API version 2024-06-01 +func (client *CloudsClient) deleteOperation(ctx context.Context, resourceGroupName string, cloudResourceName string, options *CloudsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "CloudsClient.BeginDelete" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.deleteCreateRequest(ctx, resourceGroupName, cloudName, options) + req, err := client.deleteCreateRequest(ctx, resourceGroupName, cloudResourceName, options) if err != nil { return nil, err } @@ -168,7 +167,7 @@ func (client *CloudsClient) deleteOperation(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -176,8 +175,8 @@ func (client *CloudsClient) deleteOperation(ctx context.Context, resourceGroupNa } // deleteCreateRequest creates the Delete request. -func (client *CloudsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, cloudName string, options *CloudsClientBeginDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}" +func (client *CloudsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, cloudResourceName string, options *CloudsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudResourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -186,18 +185,18 @@ func (client *CloudsClient) deleteCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if cloudName == "" { - return nil, errors.New("parameter cloudName cannot be empty") + if cloudResourceName == "" { + return nil, errors.New("parameter cloudResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{cloudName}", url.PathEscape(cloudName)) + urlPath = strings.ReplaceAll(urlPath, "{cloudResourceName}", url.PathEscape(cloudResourceName)) 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", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") if options != nil && options.Force != nil { - reqQP.Set("force", strconv.FormatBool(*options.Force)) + reqQP.Set("force", string(*options.Force)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} @@ -207,17 +206,17 @@ func (client *CloudsClient) deleteCreateRequest(ctx context.Context, resourceGro // Get - Implements Cloud GET method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - cloudName - Name of the Cloud. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - cloudResourceName - Name of the Cloud. // - options - CloudsClientGetOptions contains the optional parameters for the CloudsClient.Get method. -func (client *CloudsClient) Get(ctx context.Context, resourceGroupName string, cloudName string, options *CloudsClientGetOptions) (CloudsClientGetResponse, error) { +func (client *CloudsClient) Get(ctx context.Context, resourceGroupName string, cloudResourceName string, options *CloudsClientGetOptions) (CloudsClientGetResponse, error) { var err error const operationName = "CloudsClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, resourceGroupName, cloudName, options) + req, err := client.getCreateRequest(ctx, resourceGroupName, cloudResourceName, options) if err != nil { return CloudsClientGetResponse{}, err } @@ -234,8 +233,8 @@ func (client *CloudsClient) Get(ctx context.Context, resourceGroupName string, c } // getCreateRequest creates the Get request. -func (client *CloudsClient) getCreateRequest(ctx context.Context, resourceGroupName string, cloudName string, options *CloudsClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}" +func (client *CloudsClient) getCreateRequest(ctx context.Context, resourceGroupName string, cloudResourceName string, options *CloudsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudResourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -244,16 +243,16 @@ func (client *CloudsClient) getCreateRequest(ctx context.Context, resourceGroupN return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if cloudName == "" { - return nil, errors.New("parameter cloudName cannot be empty") + if cloudResourceName == "" { + return nil, errors.New("parameter cloudResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{cloudName}", url.PathEscape(cloudName)) + urlPath = strings.ReplaceAll(urlPath, "{cloudResourceName}", url.PathEscape(cloudResourceName)) 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", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -270,8 +269,8 @@ func (client *CloudsClient) getHandleResponse(resp *http.Response) (CloudsClient // NewListByResourceGroupPager - List of Clouds in a resource group. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - CloudsClientListByResourceGroupOptions contains the optional parameters for the CloudsClient.NewListByResourceGroupPager // method. func (client *CloudsClient) NewListByResourceGroupPager(resourceGroupName string, options *CloudsClientListByResourceGroupOptions) *runtime.Pager[CloudsClientListByResourceGroupResponse] { @@ -313,7 +312,7 @@ func (client *CloudsClient) listByResourceGroupCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -330,7 +329,7 @@ func (client *CloudsClient) listByResourceGroupHandleResponse(resp *http.Respons // NewListBySubscriptionPager - List of Clouds in a subscription. // -// Generated from API version 2020-06-05-preview +// Generated from API version 2024-06-01 // - options - CloudsClientListBySubscriptionOptions contains the optional parameters for the CloudsClient.NewListBySubscriptionPager // method. func (client *CloudsClient) NewListBySubscriptionPager(options *CloudsClientListBySubscriptionOptions) *runtime.Pager[CloudsClientListBySubscriptionResponse] { @@ -368,7 +367,7 @@ func (client *CloudsClient) listBySubscriptionCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -386,14 +385,14 @@ func (client *CloudsClient) listBySubscriptionHandleResponse(resp *http.Response // BeginUpdate - Updates the Clouds resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - cloudName - Name of the Cloud. -// - body - Clouds patch payload. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - cloudResourceName - Name of the Cloud. +// - properties - The resource properties to be updated. // - options - CloudsClientBeginUpdateOptions contains the optional parameters for the CloudsClient.BeginUpdate method. -func (client *CloudsClient) BeginUpdate(ctx context.Context, resourceGroupName string, cloudName string, body ResourcePatch, options *CloudsClientBeginUpdateOptions) (*runtime.Poller[CloudsClientUpdateResponse], error) { +func (client *CloudsClient) BeginUpdate(ctx context.Context, resourceGroupName string, cloudResourceName string, properties CloudTagsUpdate, options *CloudsClientBeginUpdateOptions) (*runtime.Poller[CloudsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.update(ctx, resourceGroupName, cloudName, body, options) + resp, err := client.update(ctx, resourceGroupName, cloudResourceName, properties, options) if err != nil { return nil, err } @@ -412,14 +411,14 @@ func (client *CloudsClient) BeginUpdate(ctx context.Context, resourceGroupName s // Update - Updates the Clouds resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -func (client *CloudsClient) update(ctx context.Context, resourceGroupName string, cloudName string, body ResourcePatch, options *CloudsClientBeginUpdateOptions) (*http.Response, error) { +// Generated from API version 2024-06-01 +func (client *CloudsClient) update(ctx context.Context, resourceGroupName string, cloudResourceName string, properties CloudTagsUpdate, options *CloudsClientBeginUpdateOptions) (*http.Response, error) { var err error const operationName = "CloudsClient.BeginUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, resourceGroupName, cloudName, body, options) + req, err := client.updateCreateRequest(ctx, resourceGroupName, cloudResourceName, properties, options) if err != nil { return nil, err } @@ -427,7 +426,7 @@ func (client *CloudsClient) update(ctx context.Context, resourceGroupName string if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -435,29 +434,29 @@ func (client *CloudsClient) update(ctx context.Context, resourceGroupName string } // updateCreateRequest creates the Update request. -func (client *CloudsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, cloudName string, body ResourcePatch, options *CloudsClientBeginUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) +func (client *CloudsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, cloudResourceName string, properties CloudTagsUpdate, options *CloudsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/clouds/{cloudResourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if cloudName == "" { - return nil, errors.New("parameter cloudName cannot be empty") + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if cloudResourceName == "" { + return nil, errors.New("parameter cloudResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{cloudName}", url.PathEscape(cloudName)) + urlPath = strings.ReplaceAll(urlPath, "{cloudResourceName}", url.PathEscape(cloudResourceName)) 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", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, body); err != nil { + if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } return req, nil diff --git a/sdk/resourcemanager/scvmm/armscvmm/clouds_client_example_test.go b/sdk/resourcemanager/scvmm/armscvmm/clouds_client_example_test.go deleted file mode 100644 index efe39cb009db..000000000000 --- a/sdk/resourcemanager/scvmm/armscvmm/clouds_client_example_test.go +++ /dev/null @@ -1,258 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// 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 armscvmm_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/scvmm/armscvmm" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/GetCloud.json -func ExampleCloudsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCloudsClient().Get(ctx, "testrg", "HRCloud", 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.Cloud = armscvmm.Cloud{ - // Name: to.Ptr("HRCloud"), - // Type: to.Ptr("Microsoft.SCVMM/Clouds"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/Clouds/HRCloud"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.CloudProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/CreateCloud.json -func ExampleCloudsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewCloudsClient().BeginCreateOrUpdate(ctx, "testrg", "HRCloud", armscvmm.Cloud{ - ExtendedLocation: &armscvmm.ExtendedLocation{ - Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - Type: to.Ptr("customLocation"), - }, - Location: to.Ptr("East US"), - Properties: &armscvmm.CloudProperties{ - UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - }, - }, 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.Cloud = armscvmm.Cloud{ - // Name: to.Ptr("HRCloud"), - // Type: to.Ptr("Microsoft.SCVMM/Clouds"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/Clouds/HRCloud"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.CloudProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/DeleteCloud.json -func ExampleCloudsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewCloudsClient().BeginDelete(ctx, "testrg", "HRCloud", &armscvmm.CloudsClientBeginDeleteOptions{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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/UpdateCloud.json -func ExampleCloudsClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewCloudsClient().BeginUpdate(ctx, "testrg", "HRCloud", armscvmm.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) - } - 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.Cloud = armscvmm.Cloud{ - // Name: to.Ptr("HRCloud"), - // Type: to.Ptr("Microsoft.SCVMM/Clouds"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/Clouds/HRCloud"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.CloudProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListCloudsByResourceGroup.json -func ExampleCloudsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewCloudsClient().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.CloudListResult = armscvmm.CloudListResult{ - // Value: []*armscvmm.Cloud{ - // { - // Name: to.Ptr("HRCloud"), - // Type: to.Ptr("Microsoft.SCVMM/Clouds"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/Clouds/HRCloud"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.CloudProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListCloudsBySubscription.json -func ExampleCloudsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewCloudsClient().NewListBySubscriptionPager(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.CloudListResult = armscvmm.CloudListResult{ - // Value: []*armscvmm.Cloud{ - // { - // Name: to.Ptr("HRCloud"), - // Type: to.Ptr("Microsoft.SCVMM/Clouds"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/Clouds/HRCloud"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.CloudProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/scvmm/armscvmm/constants.go b/sdk/resourcemanager/scvmm/armscvmm/constants.go index 6d239df21ce1..7c68e179fa2f 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/constants.go +++ b/sdk/resourcemanager/scvmm/armscvmm/constants.go @@ -10,15 +10,31 @@ package armscvmm const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/scvmm/armscvmm" - moduleVersion = "v0.4.0" + moduleVersion = "v1.0.0" ) -// AllocationMethod - Allocation method. +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// AllocationMethod - Network address allocation method. type AllocationMethod string const ( + // AllocationMethodDynamic - Dynamically allocated address. AllocationMethodDynamic AllocationMethod = "Dynamic" - AllocationMethodStatic AllocationMethod = "Static" + // AllocationMethodStatic - Statically allocated address. + AllocationMethodStatic AllocationMethod = "Static" ) // PossibleAllocationMethodValues returns the possible values for the AllocationMethod const type. @@ -29,12 +45,14 @@ func PossibleAllocationMethodValues() []AllocationMethod { } } -// CreateDiffDisk - Gets or sets a value indicating diff disk. +// CreateDiffDisk - Create diff disk. type CreateDiffDisk string const ( + // CreateDiffDiskFalse - Disable create diff disk. CreateDiffDiskFalse CreateDiffDisk = "false" - CreateDiffDiskTrue CreateDiffDisk = "true" + // CreateDiffDiskTrue - Enable create diff disk. + CreateDiffDiskTrue CreateDiffDisk = "true" ) // PossibleCreateDiffDiskValues returns the possible values for the CreateDiffDisk const type. @@ -65,12 +83,31 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } -// DynamicMemoryEnabled - Gets or sets a value indicating whether to enable dynamic memory or not. +type DeleteFromHost string + +const ( + // DeleteFromHostFalse - Disable delete from host. + DeleteFromHostFalse DeleteFromHost = "false" + // DeleteFromHostTrue - Enable delete from host. + DeleteFromHostTrue DeleteFromHost = "true" +) + +// PossibleDeleteFromHostValues returns the possible values for the DeleteFromHost const type. +func PossibleDeleteFromHostValues() []DeleteFromHost { + return []DeleteFromHost{ + DeleteFromHostFalse, + DeleteFromHostTrue, + } +} + +// DynamicMemoryEnabled - Dynamic memory enabled. type DynamicMemoryEnabled string const ( + // DynamicMemoryEnabledFalse - Disable dynamic memory. DynamicMemoryEnabledFalse DynamicMemoryEnabled = "false" - DynamicMemoryEnabledTrue DynamicMemoryEnabled = "true" + // DynamicMemoryEnabledTrue - Enable dynamic memory. + DynamicMemoryEnabledTrue DynamicMemoryEnabled = "true" ) // PossibleDynamicMemoryEnabledValues returns the possible values for the DynamicMemoryEnabled const type. @@ -81,14 +118,35 @@ func PossibleDynamicMemoryEnabledValues() []DynamicMemoryEnabled { } } -// InventoryType - The inventory type. +type ForceDelete string + +const ( + // ForceDeleteFalse - Disable force delete. + ForceDeleteFalse ForceDelete = "false" + // ForceDeleteTrue - Enable force delete. + ForceDeleteTrue ForceDelete = "true" +) + +// PossibleForceDeleteValues returns the possible values for the ForceDelete const type. +func PossibleForceDeleteValues() []ForceDelete { + return []ForceDelete{ + ForceDeleteFalse, + ForceDeleteTrue, + } +} + +// InventoryType - The inventory type type InventoryType string const ( - InventoryTypeCloud InventoryType = "Cloud" - InventoryTypeVirtualMachine InventoryType = "VirtualMachine" + // InventoryTypeCloud - Cloud inventory type + InventoryTypeCloud InventoryType = "Cloud" + // InventoryTypeVirtualMachine - VirtualMachine inventory type + InventoryTypeVirtualMachine InventoryType = "VirtualMachine" + // InventoryTypeVirtualMachineTemplate - VirtualMachineTemplate inventory type InventoryTypeVirtualMachineTemplate InventoryType = "VirtualMachineTemplate" - InventoryTypeVirtualNetwork InventoryType = "VirtualNetwork" + // InventoryTypeVirtualNetwork - VirtualNetwork inventory type + InventoryTypeVirtualNetwork InventoryType = "VirtualNetwork" ) // PossibleInventoryTypeValues returns the possible values for the InventoryType const type. @@ -101,12 +159,14 @@ func PossibleInventoryTypeValues() []InventoryType { } } -// IsCustomizable - Gets or sets a value indicating whether the vm template is customizable or not. +// IsCustomizable - Customizable. type IsCustomizable string const ( + // IsCustomizableFalse - Disable customizable. IsCustomizableFalse IsCustomizable = "false" - IsCustomizableTrue IsCustomizable = "true" + // IsCustomizableTrue - Enable customizable. + IsCustomizableTrue IsCustomizable = "true" ) // PossibleIsCustomizableValues returns the possible values for the IsCustomizable const type. @@ -117,13 +177,32 @@ func PossibleIsCustomizableValues() []IsCustomizable { } } -// LimitCPUForMigration - Gets or sets a value indicating whether to enable processor compatibility mode for live migration -// of VMs. +// IsHighlyAvailable - Highly available. +type IsHighlyAvailable string + +const ( + // IsHighlyAvailableFalse - Disable highly available. + IsHighlyAvailableFalse IsHighlyAvailable = "false" + // IsHighlyAvailableTrue - Enable highly available. + IsHighlyAvailableTrue IsHighlyAvailable = "true" +) + +// PossibleIsHighlyAvailableValues returns the possible values for the IsHighlyAvailable const type. +func PossibleIsHighlyAvailableValues() []IsHighlyAvailable { + return []IsHighlyAvailable{ + IsHighlyAvailableFalse, + IsHighlyAvailableTrue, + } +} + +// LimitCPUForMigration - Limit CPU for migration. type LimitCPUForMigration string const ( + // LimitCPUForMigrationFalse - Disable limit CPU for migration. LimitCPUForMigrationFalse LimitCPUForMigration = "false" - LimitCPUForMigrationTrue LimitCPUForMigration = "true" + // LimitCPUForMigrationTrue - Enable limit CPU for migration. + LimitCPUForMigrationTrue LimitCPUForMigration = "true" ) // PossibleLimitCPUForMigrationValues returns the possible values for the LimitCPUForMigration const type. @@ -134,12 +213,34 @@ func PossibleLimitCPUForMigrationValues() []LimitCPUForMigration { } } -// OsType - Defines the different types of VM guest operating systems. +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// OsType - Virtual machine operating system type. type OsType string const ( - OsTypeLinux OsType = "Linux" - OsTypeOther OsType = "Other" + // OsTypeLinux - Linux operating system. + OsTypeLinux OsType = "Linux" + // OsTypeOther - Other operating system. + OsTypeOther OsType = "Other" + // OsTypeWindows - Windows operating system. OsTypeWindows OsType = "Windows" ) @@ -151,3 +252,79 @@ func PossibleOsTypeValues() []OsType { OsTypeWindows, } } + +// ProvisioningAction - Guest agent provisioning action. +type ProvisioningAction string + +const ( + // ProvisioningActionInstall - Install guest agent. + ProvisioningActionInstall ProvisioningAction = "install" + // ProvisioningActionRepair - Repair guest agent. + ProvisioningActionRepair ProvisioningAction = "repair" + // ProvisioningActionUninstall - Uninstall guest agent. + ProvisioningActionUninstall ProvisioningAction = "uninstall" +) + +// PossibleProvisioningActionValues returns the possible values for the ProvisioningAction const type. +func PossibleProvisioningActionValues() []ProvisioningAction { + return []ProvisioningAction{ + ProvisioningActionInstall, + ProvisioningActionRepair, + ProvisioningActionUninstall, + } +} + +// ProvisioningState - The provisioning state of the resource. +type ProvisioningState string + +const ( + // ProvisioningStateAccepted - The resource has been accepted. + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Resource creation was canceled. + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateCreated - The resource was created. + ProvisioningStateCreated ProvisioningState = "Created" + // ProvisioningStateDeleting - The resource is being deleted. + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Resource creation failed. + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateProvisioning - The resource is provisioning. + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateSucceeded - Resource has been created. + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - The resource is updating. + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateCreated, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateProvisioning, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// SkipShutdown - Gets or sets a value indicating whether to request non-graceful VM shutdown. True value for this flag indicates +// non-graceful shutdown whereas false indicates otherwise. Defaults to false. +type SkipShutdown string + +const ( + // SkipShutdownFalse - Disable skip shutdown. + SkipShutdownFalse SkipShutdown = "false" + // SkipShutdownTrue - Enable skip shutdown. + SkipShutdownTrue SkipShutdown = "true" +) + +// PossibleSkipShutdownValues returns the possible values for the SkipShutdown const type. +func PossibleSkipShutdownValues() []SkipShutdown { + return []SkipShutdown{ + SkipShutdownFalse, + SkipShutdownTrue, + } +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/fake/availabilitysets_server.go b/sdk/resourcemanager/scvmm/armscvmm/fake/availabilitysets_server.go index fd573f3272b5..a3357a05ca99 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/fake/availabilitysets_server.go +++ b/sdk/resourcemanager/scvmm/armscvmm/fake/availabilitysets_server.go @@ -20,22 +20,21 @@ import ( "net/http" "net/url" "regexp" - "strconv" ) // AvailabilitySetsServer is a fake server for instances of the armscvmm.AvailabilitySetsClient type. type AvailabilitySetsServer struct { // BeginCreateOrUpdate is the fake for method AvailabilitySetsClient.BeginCreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, availabilitySetName string, body armscvmm.AvailabilitySet, options *armscvmm.AvailabilitySetsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armscvmm.AvailabilitySetsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, availabilitySetResourceName string, resource armscvmm.AvailabilitySet, options *armscvmm.AvailabilitySetsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armscvmm.AvailabilitySetsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method AvailabilitySetsClient.BeginDelete - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent - BeginDelete func(ctx context.Context, resourceGroupName string, availabilitySetName string, options *armscvmm.AvailabilitySetsClientBeginDeleteOptions) (resp azfake.PollerResponder[armscvmm.AvailabilitySetsClientDeleteResponse], errResp azfake.ErrorResponder) + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, availabilitySetResourceName string, options *armscvmm.AvailabilitySetsClientBeginDeleteOptions) (resp azfake.PollerResponder[armscvmm.AvailabilitySetsClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method AvailabilitySetsClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, resourceGroupName string, availabilitySetName string, options *armscvmm.AvailabilitySetsClientGetOptions) (resp azfake.Responder[armscvmm.AvailabilitySetsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, resourceGroupName string, availabilitySetResourceName string, options *armscvmm.AvailabilitySetsClientGetOptions) (resp azfake.Responder[armscvmm.AvailabilitySetsClientGetResponse], errResp azfake.ErrorResponder) // NewListByResourceGroupPager is the fake for method AvailabilitySetsClient.NewListByResourceGroupPager // HTTP status codes to indicate success: http.StatusOK @@ -46,8 +45,8 @@ type AvailabilitySetsServer struct { NewListBySubscriptionPager func(options *armscvmm.AvailabilitySetsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armscvmm.AvailabilitySetsClientListBySubscriptionResponse]) // BeginUpdate is the fake for method AvailabilitySetsClient.BeginUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted - BeginUpdate func(ctx context.Context, resourceGroupName string, availabilitySetName string, body armscvmm.ResourcePatch, options *armscvmm.AvailabilitySetsClientBeginUpdateOptions) (resp azfake.PollerResponder[armscvmm.AvailabilitySetsClientUpdateResponse], errResp azfake.ErrorResponder) + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, availabilitySetResourceName string, properties armscvmm.AvailabilitySetTagsUpdate, options *armscvmm.AvailabilitySetsClientBeginUpdateOptions) (resp azfake.PollerResponder[armscvmm.AvailabilitySetsClientUpdateResponse], errResp azfake.ErrorResponder) } // NewAvailabilitySetsServerTransport creates a new instance of AvailabilitySetsServerTransport with the provided implementation. @@ -116,7 +115,7 @@ func (a *AvailabilitySetsServerTransport) dispatchBeginCreateOrUpdate(req *http. } beginCreateOrUpdate := a.beginCreateOrUpdate.get(req) if beginCreateOrUpdate == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/availabilitySets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/availabilitySets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { @@ -130,11 +129,11 @@ func (a *AvailabilitySetsServerTransport) dispatchBeginCreateOrUpdate(req *http. if err != nil { return nil, err } - availabilitySetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("availabilitySetName")]) + availabilitySetResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("availabilitySetResourceName")]) if err != nil { return nil, err } - respr, errRespr := a.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, availabilitySetNameParam, body, nil) + respr, errRespr := a.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, availabilitySetResourceNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -164,7 +163,7 @@ func (a *AvailabilitySetsServerTransport) dispatchBeginDelete(req *http.Request) } beginDelete := a.beginDelete.get(req) if beginDelete == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/availabilitySets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/availabilitySets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { @@ -175,15 +174,12 @@ func (a *AvailabilitySetsServerTransport) dispatchBeginDelete(req *http.Request) if err != nil { return nil, err } - availabilitySetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("availabilitySetName")]) - if err != nil { - return nil, err - } forceUnescaped, err := url.QueryUnescape(qp.Get("force")) if err != nil { return nil, err } - forceParam, err := parseOptional(forceUnescaped, strconv.ParseBool) + forceParam := getOptional(armscvmm.ForceDelete(forceUnescaped)) + availabilitySetResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("availabilitySetResourceName")]) if err != nil { return nil, err } @@ -193,7 +189,7 @@ func (a *AvailabilitySetsServerTransport) dispatchBeginDelete(req *http.Request) Force: forceParam, } } - respr, errRespr := a.srv.BeginDelete(req.Context(), resourceGroupNameParam, availabilitySetNameParam, options) + respr, errRespr := a.srv.BeginDelete(req.Context(), resourceGroupNameParam, availabilitySetResourceNameParam, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -206,9 +202,9 @@ func (a *AvailabilitySetsServerTransport) dispatchBeginDelete(req *http.Request) return nil, err } - if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { a.beginDelete.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDelete) { a.beginDelete.remove(req) @@ -221,7 +217,7 @@ func (a *AvailabilitySetsServerTransport) dispatchGet(req *http.Request) (*http. if a.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/availabilitySets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/availabilitySets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { @@ -231,11 +227,11 @@ func (a *AvailabilitySetsServerTransport) dispatchGet(req *http.Request) (*http. if err != nil { return nil, err } - availabilitySetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("availabilitySetName")]) + availabilitySetResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("availabilitySetResourceName")]) if err != nil { return nil, err } - respr, errRespr := a.srv.Get(req.Context(), resourceGroupNameParam, availabilitySetNameParam, nil) + respr, errRespr := a.srv.Get(req.Context(), resourceGroupNameParam, availabilitySetResourceNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -326,13 +322,13 @@ func (a *AvailabilitySetsServerTransport) dispatchBeginUpdate(req *http.Request) } beginUpdate := a.beginUpdate.get(req) if beginUpdate == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/availabilitySets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/availabilitySets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armscvmm.ResourcePatch](req) + body, err := server.UnmarshalRequestAsJSON[armscvmm.AvailabilitySetTagsUpdate](req) if err != nil { return nil, err } @@ -340,11 +336,11 @@ func (a *AvailabilitySetsServerTransport) dispatchBeginUpdate(req *http.Request) if err != nil { return nil, err } - availabilitySetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("availabilitySetName")]) + availabilitySetResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("availabilitySetResourceName")]) if err != nil { return nil, err } - respr, errRespr := a.srv.BeginUpdate(req.Context(), resourceGroupNameParam, availabilitySetNameParam, body, nil) + respr, errRespr := a.srv.BeginUpdate(req.Context(), resourceGroupNameParam, availabilitySetResourceNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -357,9 +353,9 @@ func (a *AvailabilitySetsServerTransport) dispatchBeginUpdate(req *http.Request) return nil, err } - if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { a.beginUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginUpdate) { a.beginUpdate.remove(req) diff --git a/sdk/resourcemanager/scvmm/armscvmm/fake/clouds_server.go b/sdk/resourcemanager/scvmm/armscvmm/fake/clouds_server.go index 23ad951f4961..e5bb28aaa5d6 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/fake/clouds_server.go +++ b/sdk/resourcemanager/scvmm/armscvmm/fake/clouds_server.go @@ -20,22 +20,21 @@ import ( "net/http" "net/url" "regexp" - "strconv" ) // CloudsServer is a fake server for instances of the armscvmm.CloudsClient type. type CloudsServer struct { // BeginCreateOrUpdate is the fake for method CloudsClient.BeginCreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, cloudName string, body armscvmm.Cloud, options *armscvmm.CloudsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armscvmm.CloudsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, cloudResourceName string, resource armscvmm.Cloud, options *armscvmm.CloudsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armscvmm.CloudsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method CloudsClient.BeginDelete - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent - BeginDelete func(ctx context.Context, resourceGroupName string, cloudName string, options *armscvmm.CloudsClientBeginDeleteOptions) (resp azfake.PollerResponder[armscvmm.CloudsClientDeleteResponse], errResp azfake.ErrorResponder) + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, cloudResourceName string, options *armscvmm.CloudsClientBeginDeleteOptions) (resp azfake.PollerResponder[armscvmm.CloudsClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method CloudsClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, resourceGroupName string, cloudName string, options *armscvmm.CloudsClientGetOptions) (resp azfake.Responder[armscvmm.CloudsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, resourceGroupName string, cloudResourceName string, options *armscvmm.CloudsClientGetOptions) (resp azfake.Responder[armscvmm.CloudsClientGetResponse], errResp azfake.ErrorResponder) // NewListByResourceGroupPager is the fake for method CloudsClient.NewListByResourceGroupPager // HTTP status codes to indicate success: http.StatusOK @@ -46,8 +45,8 @@ type CloudsServer struct { NewListBySubscriptionPager func(options *armscvmm.CloudsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armscvmm.CloudsClientListBySubscriptionResponse]) // BeginUpdate is the fake for method CloudsClient.BeginUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted - BeginUpdate func(ctx context.Context, resourceGroupName string, cloudName string, body armscvmm.ResourcePatch, options *armscvmm.CloudsClientBeginUpdateOptions) (resp azfake.PollerResponder[armscvmm.CloudsClientUpdateResponse], errResp azfake.ErrorResponder) + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, cloudResourceName string, properties armscvmm.CloudTagsUpdate, options *armscvmm.CloudsClientBeginUpdateOptions) (resp azfake.PollerResponder[armscvmm.CloudsClientUpdateResponse], errResp azfake.ErrorResponder) } // NewCloudsServerTransport creates a new instance of CloudsServerTransport with the provided implementation. @@ -116,7 +115,7 @@ func (c *CloudsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) ( } beginCreateOrUpdate := c.beginCreateOrUpdate.get(req) if beginCreateOrUpdate == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/clouds/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/clouds/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { @@ -130,11 +129,11 @@ func (c *CloudsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) ( if err != nil { return nil, err } - cloudNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("cloudName")]) + cloudResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("cloudResourceName")]) if err != nil { return nil, err } - respr, errRespr := c.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, cloudNameParam, body, nil) + respr, errRespr := c.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, cloudResourceNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -164,7 +163,7 @@ func (c *CloudsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Re } beginDelete := c.beginDelete.get(req) if beginDelete == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/clouds/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/clouds/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { @@ -175,15 +174,12 @@ func (c *CloudsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Re if err != nil { return nil, err } - cloudNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("cloudName")]) - if err != nil { - return nil, err - } forceUnescaped, err := url.QueryUnescape(qp.Get("force")) if err != nil { return nil, err } - forceParam, err := parseOptional(forceUnescaped, strconv.ParseBool) + forceParam := getOptional(armscvmm.ForceDelete(forceUnescaped)) + cloudResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("cloudResourceName")]) if err != nil { return nil, err } @@ -193,7 +189,7 @@ func (c *CloudsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Re Force: forceParam, } } - respr, errRespr := c.srv.BeginDelete(req.Context(), resourceGroupNameParam, cloudNameParam, options) + respr, errRespr := c.srv.BeginDelete(req.Context(), resourceGroupNameParam, cloudResourceNameParam, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -206,9 +202,9 @@ func (c *CloudsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Re return nil, err } - if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { c.beginDelete.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDelete) { c.beginDelete.remove(req) @@ -221,7 +217,7 @@ func (c *CloudsServerTransport) dispatchGet(req *http.Request) (*http.Response, if c.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/clouds/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/clouds/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { @@ -231,11 +227,11 @@ func (c *CloudsServerTransport) dispatchGet(req *http.Request) (*http.Response, if err != nil { return nil, err } - cloudNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("cloudName")]) + cloudResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("cloudResourceName")]) if err != nil { return nil, err } - respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, cloudNameParam, nil) + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, cloudResourceNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -326,13 +322,13 @@ func (c *CloudsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Re } beginUpdate := c.beginUpdate.get(req) if beginUpdate == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/clouds/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/clouds/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armscvmm.ResourcePatch](req) + body, err := server.UnmarshalRequestAsJSON[armscvmm.CloudTagsUpdate](req) if err != nil { return nil, err } @@ -340,11 +336,11 @@ func (c *CloudsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Re if err != nil { return nil, err } - cloudNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("cloudName")]) + cloudResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("cloudResourceName")]) if err != nil { return nil, err } - respr, errRespr := c.srv.BeginUpdate(req.Context(), resourceGroupNameParam, cloudNameParam, body, nil) + respr, errRespr := c.srv.BeginUpdate(req.Context(), resourceGroupNameParam, cloudResourceNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -357,9 +353,9 @@ func (c *CloudsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Re return nil, err } - if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { c.beginUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginUpdate) { c.beginUpdate.remove(req) diff --git a/sdk/resourcemanager/scvmm/armscvmm/fake/guestagents_server.go b/sdk/resourcemanager/scvmm/armscvmm/fake/guestagents_server.go new file mode 100644 index 000000000000..1d9302b83e5b --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/fake/guestagents_server.go @@ -0,0 +1,231 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/scvmm/armscvmm" + "net/http" + "net/url" + "regexp" +) + +// GuestAgentsServer is a fake server for instances of the armscvmm.GuestAgentsClient type. +type GuestAgentsServer struct { + // BeginCreate is the fake for method GuestAgentsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceURI string, resource armscvmm.GuestAgent, options *armscvmm.GuestAgentsClientBeginCreateOptions) (resp azfake.PollerResponder[armscvmm.GuestAgentsClientCreateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method GuestAgentsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceURI string, options *armscvmm.GuestAgentsClientDeleteOptions) (resp azfake.Responder[armscvmm.GuestAgentsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method GuestAgentsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceURI string, options *armscvmm.GuestAgentsClientGetOptions) (resp azfake.Responder[armscvmm.GuestAgentsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByVirtualMachineInstancePager is the fake for method GuestAgentsClient.NewListByVirtualMachineInstancePager + // HTTP status codes to indicate success: http.StatusOK + NewListByVirtualMachineInstancePager func(resourceURI string, options *armscvmm.GuestAgentsClientListByVirtualMachineInstanceOptions) (resp azfake.PagerResponder[armscvmm.GuestAgentsClientListByVirtualMachineInstanceResponse]) +} + +// NewGuestAgentsServerTransport creates a new instance of GuestAgentsServerTransport with the provided implementation. +// The returned GuestAgentsServerTransport instance is connected to an instance of armscvmm.GuestAgentsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewGuestAgentsServerTransport(srv *GuestAgentsServer) *GuestAgentsServerTransport { + return &GuestAgentsServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armscvmm.GuestAgentsClientCreateResponse]](), + newListByVirtualMachineInstancePager: newTracker[azfake.PagerResponder[armscvmm.GuestAgentsClientListByVirtualMachineInstanceResponse]](), + } +} + +// GuestAgentsServerTransport connects instances of armscvmm.GuestAgentsClient to instances of GuestAgentsServer. +// Don't use this type directly, use NewGuestAgentsServerTransport instead. +type GuestAgentsServerTransport struct { + srv *GuestAgentsServer + beginCreate *tracker[azfake.PollerResponder[armscvmm.GuestAgentsClientCreateResponse]] + newListByVirtualMachineInstancePager *tracker[azfake.PagerResponder[armscvmm.GuestAgentsClientListByVirtualMachineInstanceResponse]] +} + +// Do implements the policy.Transporter interface for GuestAgentsServerTransport. +func (g *GuestAgentsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "GuestAgentsClient.BeginCreate": + resp, err = g.dispatchBeginCreate(req) + case "GuestAgentsClient.Delete": + resp, err = g.dispatchDelete(req) + case "GuestAgentsClient.Get": + resp, err = g.dispatchGet(req) + case "GuestAgentsClient.NewListByVirtualMachineInstancePager": + resp, err = g.dispatchNewListByVirtualMachineInstancePager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (g *GuestAgentsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if g.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := g.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachineInstances/default/guestAgents/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armscvmm.GuestAgent](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := g.srv.BeginCreate(req.Context(), resourceURIParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + g.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + g.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + g.beginCreate.remove(req) + } + + return resp, nil +} + +func (g *GuestAgentsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if g.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachineInstances/default/guestAgents/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := g.srv.Delete(req.Context(), resourceURIParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (g *GuestAgentsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if g.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachineInstances/default/guestAgents/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := g.srv.Get(req.Context(), resourceURIParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).GuestAgent, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (g *GuestAgentsServerTransport) dispatchNewListByVirtualMachineInstancePager(req *http.Request) (*http.Response, error) { + if g.srv.NewListByVirtualMachineInstancePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByVirtualMachineInstancePager not implemented")} + } + newListByVirtualMachineInstancePager := g.newListByVirtualMachineInstancePager.get(req) + if newListByVirtualMachineInstancePager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachineInstances/default/guestAgents` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + resp := g.srv.NewListByVirtualMachineInstancePager(resourceURIParam, nil) + newListByVirtualMachineInstancePager = &resp + g.newListByVirtualMachineInstancePager.add(req, newListByVirtualMachineInstancePager) + server.PagerResponderInjectNextLinks(newListByVirtualMachineInstancePager, req, func(page *armscvmm.GuestAgentsClientListByVirtualMachineInstanceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByVirtualMachineInstancePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + g.newListByVirtualMachineInstancePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByVirtualMachineInstancePager) { + g.newListByVirtualMachineInstancePager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/fake/internal.go b/sdk/resourcemanager/scvmm/armscvmm/fake/internal.go index 4d8bd36394ec..94e060e89dbd 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/fake/internal.go +++ b/sdk/resourcemanager/scvmm/armscvmm/fake/internal.go @@ -11,6 +11,7 @@ package fake import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "net/http" + "reflect" "sync" ) @@ -31,15 +32,11 @@ func contains[T comparable](s []T, v T) bool { return false } -func parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) { - if v == "" { - return nil, nil +func getOptional[T any](v T) *T { + if reflect.ValueOf(v).IsZero() { + return nil } - t, err := parse(v) - if err != nil { - return nil, err - } - return &t, err + return &v } func newTracker[T any]() *tracker[T] { diff --git a/sdk/resourcemanager/scvmm/armscvmm/fake/inventoryitems_server.go b/sdk/resourcemanager/scvmm/armscvmm/fake/inventoryitems_server.go index 167f8ac1677e..f8df37d81ce9 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/fake/inventoryitems_server.go +++ b/sdk/resourcemanager/scvmm/armscvmm/fake/inventoryitems_server.go @@ -19,27 +19,26 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/scvmm/armscvmm" "net/http" "net/url" - "reflect" "regexp" ) // InventoryItemsServer is a fake server for instances of the armscvmm.InventoryItemsClient type. type InventoryItemsServer struct { // Create is the fake for method InventoryItemsClient.Create - // HTTP status codes to indicate success: http.StatusOK - Create func(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemName string, options *armscvmm.InventoryItemsClientCreateOptions) (resp azfake.Responder[armscvmm.InventoryItemsClientCreateResponse], errResp azfake.ErrorResponder) + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + Create func(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemResourceName string, resource armscvmm.InventoryItem, options *armscvmm.InventoryItemsClientCreateOptions) (resp azfake.Responder[armscvmm.InventoryItemsClientCreateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method InventoryItemsClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemName string, options *armscvmm.InventoryItemsClientDeleteOptions) (resp azfake.Responder[armscvmm.InventoryItemsClientDeleteResponse], errResp azfake.ErrorResponder) + Delete func(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemResourceName string, options *armscvmm.InventoryItemsClientDeleteOptions) (resp azfake.Responder[armscvmm.InventoryItemsClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method InventoryItemsClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemName string, options *armscvmm.InventoryItemsClientGetOptions) (resp azfake.Responder[armscvmm.InventoryItemsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemResourceName string, options *armscvmm.InventoryItemsClientGetOptions) (resp azfake.Responder[armscvmm.InventoryItemsClientGetResponse], errResp azfake.ErrorResponder) - // NewListByVMMServerPager is the fake for method InventoryItemsClient.NewListByVMMServerPager + // NewListByVmmServerPager is the fake for method InventoryItemsClient.NewListByVmmServerPager // HTTP status codes to indicate success: http.StatusOK - NewListByVMMServerPager func(resourceGroupName string, vmmServerName string, options *armscvmm.InventoryItemsClientListByVMMServerOptions) (resp azfake.PagerResponder[armscvmm.InventoryItemsClientListByVMMServerResponse]) + NewListByVmmServerPager func(resourceGroupName string, vmmServerName string, options *armscvmm.InventoryItemsClientListByVmmServerOptions) (resp azfake.PagerResponder[armscvmm.InventoryItemsClientListByVmmServerResponse]) } // NewInventoryItemsServerTransport creates a new instance of InventoryItemsServerTransport with the provided implementation. @@ -48,7 +47,7 @@ type InventoryItemsServer struct { func NewInventoryItemsServerTransport(srv *InventoryItemsServer) *InventoryItemsServerTransport { return &InventoryItemsServerTransport{ srv: srv, - newListByVMMServerPager: newTracker[azfake.PagerResponder[armscvmm.InventoryItemsClientListByVMMServerResponse]](), + newListByVmmServerPager: newTracker[azfake.PagerResponder[armscvmm.InventoryItemsClientListByVmmServerResponse]](), } } @@ -56,7 +55,7 @@ func NewInventoryItemsServerTransport(srv *InventoryItemsServer) *InventoryItems // Don't use this type directly, use NewInventoryItemsServerTransport instead. type InventoryItemsServerTransport struct { srv *InventoryItemsServer - newListByVMMServerPager *tracker[azfake.PagerResponder[armscvmm.InventoryItemsClientListByVMMServerResponse]] + newListByVmmServerPager *tracker[azfake.PagerResponder[armscvmm.InventoryItemsClientListByVmmServerResponse]] } // Do implements the policy.Transporter interface for InventoryItemsServerTransport. @@ -77,8 +76,8 @@ func (i *InventoryItemsServerTransport) Do(req *http.Request) (*http.Response, e resp, err = i.dispatchDelete(req) case "InventoryItemsClient.Get": resp, err = i.dispatchGet(req) - case "InventoryItemsClient.NewListByVMMServerPager": - resp, err = i.dispatchNewListByVMMServerPager(req) + case "InventoryItemsClient.NewListByVmmServerPager": + resp, err = i.dispatchNewListByVmmServerPager(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -94,7 +93,7 @@ func (i *InventoryItemsServerTransport) dispatchCreate(req *http.Request) (*http if i.srv.Create == nil { return nil, &nonRetriableError{errors.New("fake for method Create not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/vmmServers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/inventoryItems/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/vmmServers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/inventoryItems/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { @@ -112,23 +111,17 @@ func (i *InventoryItemsServerTransport) dispatchCreate(req *http.Request) (*http if err != nil { return nil, err } - inventoryItemNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("inventoryItemName")]) + inventoryItemResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("inventoryItemResourceName")]) if err != nil { return nil, err } - var options *armscvmm.InventoryItemsClientCreateOptions - if !reflect.ValueOf(body).IsZero() { - options = &armscvmm.InventoryItemsClientCreateOptions{ - Body: &body, - } - } - respr, errRespr := i.srv.Create(req.Context(), resourceGroupNameParam, vmmServerNameParam, inventoryItemNameParam, options) + respr, errRespr := i.srv.Create(req.Context(), resourceGroupNameParam, vmmServerNameParam, inventoryItemResourceNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} } resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).InventoryItem, req) if err != nil { @@ -141,7 +134,7 @@ func (i *InventoryItemsServerTransport) dispatchDelete(req *http.Request) (*http if i.srv.Delete == nil { return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/vmmServers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/inventoryItems/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/vmmServers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/inventoryItems/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { @@ -155,11 +148,11 @@ func (i *InventoryItemsServerTransport) dispatchDelete(req *http.Request) (*http if err != nil { return nil, err } - inventoryItemNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("inventoryItemName")]) + inventoryItemResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("inventoryItemResourceName")]) if err != nil { return nil, err } - respr, errRespr := i.srv.Delete(req.Context(), resourceGroupNameParam, vmmServerNameParam, inventoryItemNameParam, nil) + respr, errRespr := i.srv.Delete(req.Context(), resourceGroupNameParam, vmmServerNameParam, inventoryItemResourceNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -178,7 +171,7 @@ func (i *InventoryItemsServerTransport) dispatchGet(req *http.Request) (*http.Re if i.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/vmmServers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/inventoryItems/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/vmmServers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/inventoryItems/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { @@ -192,11 +185,11 @@ func (i *InventoryItemsServerTransport) dispatchGet(req *http.Request) (*http.Re if err != nil { return nil, err } - inventoryItemNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("inventoryItemName")]) + inventoryItemResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("inventoryItemResourceName")]) if err != nil { return nil, err } - respr, errRespr := i.srv.Get(req.Context(), resourceGroupNameParam, vmmServerNameParam, inventoryItemNameParam, nil) + respr, errRespr := i.srv.Get(req.Context(), resourceGroupNameParam, vmmServerNameParam, inventoryItemResourceNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -211,12 +204,12 @@ func (i *InventoryItemsServerTransport) dispatchGet(req *http.Request) (*http.Re return resp, nil } -func (i *InventoryItemsServerTransport) dispatchNewListByVMMServerPager(req *http.Request) (*http.Response, error) { - if i.srv.NewListByVMMServerPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListByVMMServerPager not implemented")} +func (i *InventoryItemsServerTransport) dispatchNewListByVmmServerPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListByVmmServerPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByVmmServerPager not implemented")} } - newListByVMMServerPager := i.newListByVMMServerPager.get(req) - if newListByVMMServerPager == nil { + newListByVmmServerPager := i.newListByVmmServerPager.get(req) + if newListByVmmServerPager == nil { const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/vmmServers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/inventoryItems` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) @@ -231,23 +224,23 @@ func (i *InventoryItemsServerTransport) dispatchNewListByVMMServerPager(req *htt if err != nil { return nil, err } - resp := i.srv.NewListByVMMServerPager(resourceGroupNameParam, vmmServerNameParam, nil) - newListByVMMServerPager = &resp - i.newListByVMMServerPager.add(req, newListByVMMServerPager) - server.PagerResponderInjectNextLinks(newListByVMMServerPager, req, func(page *armscvmm.InventoryItemsClientListByVMMServerResponse, createLink func() string) { + resp := i.srv.NewListByVmmServerPager(resourceGroupNameParam, vmmServerNameParam, nil) + newListByVmmServerPager = &resp + i.newListByVmmServerPager.add(req, newListByVmmServerPager) + server.PagerResponderInjectNextLinks(newListByVmmServerPager, req, func(page *armscvmm.InventoryItemsClientListByVmmServerResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } - resp, err := server.PagerResponderNext(newListByVMMServerPager, req) + resp, err := server.PagerResponderNext(newListByVmmServerPager, req) if err != nil { return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - i.newListByVMMServerPager.remove(req) + i.newListByVmmServerPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - if !server.PagerResponderMore(newListByVMMServerPager) { - i.newListByVMMServerPager.remove(req) + if !server.PagerResponderMore(newListByVmmServerPager) { + i.newListByVmmServerPager.remove(req) } return resp, nil } diff --git a/sdk/resourcemanager/scvmm/armscvmm/fake/server_factory.go b/sdk/resourcemanager/scvmm/armscvmm/fake/server_factory.go index a08d48366da1..df22ef4394fd 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/fake/server_factory.go +++ b/sdk/resourcemanager/scvmm/armscvmm/fake/server_factory.go @@ -19,14 +19,16 @@ import ( // ServerFactory is a fake server for instances of the armscvmm.ClientFactory type. type ServerFactory struct { - AvailabilitySetsServer AvailabilitySetsServer - CloudsServer CloudsServer - InventoryItemsServer InventoryItemsServer - OperationsServer OperationsServer - VirtualMachineTemplatesServer VirtualMachineTemplatesServer - VirtualMachinesServer VirtualMachinesServer - VirtualNetworksServer VirtualNetworksServer - VmmServersServer VmmServersServer + AvailabilitySetsServer AvailabilitySetsServer + CloudsServer CloudsServer + GuestAgentsServer GuestAgentsServer + InventoryItemsServer InventoryItemsServer + OperationsServer OperationsServer + VMInstanceHybridIdentityMetadatasServer VMInstanceHybridIdentityMetadatasServer + VirtualMachineInstancesServer VirtualMachineInstancesServer + VirtualMachineTemplatesServer VirtualMachineTemplatesServer + VirtualNetworksServer VirtualNetworksServer + VmmServersServer VmmServersServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -41,16 +43,18 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { // ServerFactoryTransport connects instances of armscvmm.ClientFactory to instances of ServerFactory. // Don't use this type directly, use NewServerFactoryTransport instead. type ServerFactoryTransport struct { - srv *ServerFactory - trMu sync.Mutex - trAvailabilitySetsServer *AvailabilitySetsServerTransport - trCloudsServer *CloudsServerTransport - trInventoryItemsServer *InventoryItemsServerTransport - trOperationsServer *OperationsServerTransport - trVirtualMachineTemplatesServer *VirtualMachineTemplatesServerTransport - trVirtualMachinesServer *VirtualMachinesServerTransport - trVirtualNetworksServer *VirtualNetworksServerTransport - trVmmServersServer *VmmServersServerTransport + srv *ServerFactory + trMu sync.Mutex + trAvailabilitySetsServer *AvailabilitySetsServerTransport + trCloudsServer *CloudsServerTransport + trGuestAgentsServer *GuestAgentsServerTransport + trInventoryItemsServer *InventoryItemsServerTransport + trOperationsServer *OperationsServerTransport + trVMInstanceHybridIdentityMetadatasServer *VMInstanceHybridIdentityMetadatasServerTransport + trVirtualMachineInstancesServer *VirtualMachineInstancesServerTransport + trVirtualMachineTemplatesServer *VirtualMachineTemplatesServerTransport + trVirtualNetworksServer *VirtualNetworksServerTransport + trVmmServersServer *VmmServersServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -74,6 +78,9 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "CloudsClient": initServer(s, &s.trCloudsServer, func() *CloudsServerTransport { return NewCloudsServerTransport(&s.srv.CloudsServer) }) resp, err = s.trCloudsServer.Do(req) + case "GuestAgentsClient": + initServer(s, &s.trGuestAgentsServer, func() *GuestAgentsServerTransport { return NewGuestAgentsServerTransport(&s.srv.GuestAgentsServer) }) + resp, err = s.trGuestAgentsServer.Do(req) case "InventoryItemsClient": initServer(s, &s.trInventoryItemsServer, func() *InventoryItemsServerTransport { return NewInventoryItemsServerTransport(&s.srv.InventoryItemsServer) @@ -82,16 +89,21 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "OperationsClient": initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) resp, err = s.trOperationsServer.Do(req) + case "VMInstanceHybridIdentityMetadatasClient": + initServer(s, &s.trVMInstanceHybridIdentityMetadatasServer, func() *VMInstanceHybridIdentityMetadatasServerTransport { + return NewVMInstanceHybridIdentityMetadatasServerTransport(&s.srv.VMInstanceHybridIdentityMetadatasServer) + }) + resp, err = s.trVMInstanceHybridIdentityMetadatasServer.Do(req) + case "VirtualMachineInstancesClient": + initServer(s, &s.trVirtualMachineInstancesServer, func() *VirtualMachineInstancesServerTransport { + return NewVirtualMachineInstancesServerTransport(&s.srv.VirtualMachineInstancesServer) + }) + resp, err = s.trVirtualMachineInstancesServer.Do(req) case "VirtualMachineTemplatesClient": initServer(s, &s.trVirtualMachineTemplatesServer, func() *VirtualMachineTemplatesServerTransport { return NewVirtualMachineTemplatesServerTransport(&s.srv.VirtualMachineTemplatesServer) }) resp, err = s.trVirtualMachineTemplatesServer.Do(req) - case "VirtualMachinesClient": - initServer(s, &s.trVirtualMachinesServer, func() *VirtualMachinesServerTransport { - return NewVirtualMachinesServerTransport(&s.srv.VirtualMachinesServer) - }) - resp, err = s.trVirtualMachinesServer.Do(req) case "VirtualNetworksClient": initServer(s, &s.trVirtualNetworksServer, func() *VirtualNetworksServerTransport { return NewVirtualNetworksServerTransport(&s.srv.VirtualNetworksServer) diff --git a/sdk/resourcemanager/scvmm/armscvmm/fake/time_rfc3339.go b/sdk/resourcemanager/scvmm/armscvmm/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/fake/time_rfc3339.go +++ b/sdk/resourcemanager/scvmm/armscvmm/fake/time_rfc3339.go @@ -19,12 +19,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +44,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/scvmm/armscvmm/fake/virtualmachineinstances_server.go b/sdk/resourcemanager/scvmm/armscvmm/fake/virtualmachineinstances_server.go new file mode 100644 index 000000000000..eabd181b08ba --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/fake/virtualmachineinstances_server.go @@ -0,0 +1,618 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/scvmm/armscvmm" + "net/http" + "net/url" + "regexp" +) + +// VirtualMachineInstancesServer is a fake server for instances of the armscvmm.VirtualMachineInstancesClient type. +type VirtualMachineInstancesServer struct { + // BeginCreateCheckpoint is the fake for method VirtualMachineInstancesClient.BeginCreateCheckpoint + // HTTP status codes to indicate success: http.StatusAccepted + BeginCreateCheckpoint func(ctx context.Context, resourceURI string, body armscvmm.VirtualMachineCreateCheckpoint, options *armscvmm.VirtualMachineInstancesClientBeginCreateCheckpointOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientCreateCheckpointResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method VirtualMachineInstancesClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceURI string, resource armscvmm.VirtualMachineInstance, options *armscvmm.VirtualMachineInstancesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method VirtualMachineInstancesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceURI string, options *armscvmm.VirtualMachineInstancesClientBeginDeleteOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientDeleteResponse], errResp azfake.ErrorResponder) + + // BeginDeleteCheckpoint is the fake for method VirtualMachineInstancesClient.BeginDeleteCheckpoint + // HTTP status codes to indicate success: http.StatusAccepted + BeginDeleteCheckpoint func(ctx context.Context, resourceURI string, body armscvmm.VirtualMachineDeleteCheckpoint, options *armscvmm.VirtualMachineInstancesClientBeginDeleteCheckpointOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientDeleteCheckpointResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method VirtualMachineInstancesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceURI string, options *armscvmm.VirtualMachineInstancesClientGetOptions) (resp azfake.Responder[armscvmm.VirtualMachineInstancesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method VirtualMachineInstancesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceURI string, options *armscvmm.VirtualMachineInstancesClientListOptions) (resp azfake.PagerResponder[armscvmm.VirtualMachineInstancesClientListResponse]) + + // BeginRestart is the fake for method VirtualMachineInstancesClient.BeginRestart + // HTTP status codes to indicate success: http.StatusAccepted + BeginRestart func(ctx context.Context, resourceURI string, options *armscvmm.VirtualMachineInstancesClientBeginRestartOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientRestartResponse], errResp azfake.ErrorResponder) + + // BeginRestoreCheckpoint is the fake for method VirtualMachineInstancesClient.BeginRestoreCheckpoint + // HTTP status codes to indicate success: http.StatusAccepted + BeginRestoreCheckpoint func(ctx context.Context, resourceURI string, body armscvmm.VirtualMachineRestoreCheckpoint, options *armscvmm.VirtualMachineInstancesClientBeginRestoreCheckpointOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientRestoreCheckpointResponse], errResp azfake.ErrorResponder) + + // BeginStart is the fake for method VirtualMachineInstancesClient.BeginStart + // HTTP status codes to indicate success: http.StatusAccepted + BeginStart func(ctx context.Context, resourceURI string, options *armscvmm.VirtualMachineInstancesClientBeginStartOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientStartResponse], errResp azfake.ErrorResponder) + + // BeginStop is the fake for method VirtualMachineInstancesClient.BeginStop + // HTTP status codes to indicate success: http.StatusAccepted + BeginStop func(ctx context.Context, resourceURI string, body armscvmm.StopVirtualMachineOptions, options *armscvmm.VirtualMachineInstancesClientBeginStopOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientStopResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method VirtualMachineInstancesClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceURI string, properties armscvmm.VirtualMachineInstanceUpdate, options *armscvmm.VirtualMachineInstancesClientBeginUpdateOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewVirtualMachineInstancesServerTransport creates a new instance of VirtualMachineInstancesServerTransport with the provided implementation. +// The returned VirtualMachineInstancesServerTransport instance is connected to an instance of armscvmm.VirtualMachineInstancesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewVirtualMachineInstancesServerTransport(srv *VirtualMachineInstancesServer) *VirtualMachineInstancesServerTransport { + return &VirtualMachineInstancesServerTransport{ + srv: srv, + beginCreateCheckpoint: newTracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientCreateCheckpointResponse]](), + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientDeleteResponse]](), + beginDeleteCheckpoint: newTracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientDeleteCheckpointResponse]](), + newListPager: newTracker[azfake.PagerResponder[armscvmm.VirtualMachineInstancesClientListResponse]](), + beginRestart: newTracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientRestartResponse]](), + beginRestoreCheckpoint: newTracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientRestoreCheckpointResponse]](), + beginStart: newTracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientStartResponse]](), + beginStop: newTracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientStopResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientUpdateResponse]](), + } +} + +// VirtualMachineInstancesServerTransport connects instances of armscvmm.VirtualMachineInstancesClient to instances of VirtualMachineInstancesServer. +// Don't use this type directly, use NewVirtualMachineInstancesServerTransport instead. +type VirtualMachineInstancesServerTransport struct { + srv *VirtualMachineInstancesServer + beginCreateCheckpoint *tracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientCreateCheckpointResponse]] + beginCreateOrUpdate *tracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientDeleteResponse]] + beginDeleteCheckpoint *tracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientDeleteCheckpointResponse]] + newListPager *tracker[azfake.PagerResponder[armscvmm.VirtualMachineInstancesClientListResponse]] + beginRestart *tracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientRestartResponse]] + beginRestoreCheckpoint *tracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientRestoreCheckpointResponse]] + beginStart *tracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientStartResponse]] + beginStop *tracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientStopResponse]] + beginUpdate *tracker[azfake.PollerResponder[armscvmm.VirtualMachineInstancesClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for VirtualMachineInstancesServerTransport. +func (v *VirtualMachineInstancesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "VirtualMachineInstancesClient.BeginCreateCheckpoint": + resp, err = v.dispatchBeginCreateCheckpoint(req) + case "VirtualMachineInstancesClient.BeginCreateOrUpdate": + resp, err = v.dispatchBeginCreateOrUpdate(req) + case "VirtualMachineInstancesClient.BeginDelete": + resp, err = v.dispatchBeginDelete(req) + case "VirtualMachineInstancesClient.BeginDeleteCheckpoint": + resp, err = v.dispatchBeginDeleteCheckpoint(req) + case "VirtualMachineInstancesClient.Get": + resp, err = v.dispatchGet(req) + case "VirtualMachineInstancesClient.NewListPager": + resp, err = v.dispatchNewListPager(req) + case "VirtualMachineInstancesClient.BeginRestart": + resp, err = v.dispatchBeginRestart(req) + case "VirtualMachineInstancesClient.BeginRestoreCheckpoint": + resp, err = v.dispatchBeginRestoreCheckpoint(req) + case "VirtualMachineInstancesClient.BeginStart": + resp, err = v.dispatchBeginStart(req) + case "VirtualMachineInstancesClient.BeginStop": + resp, err = v.dispatchBeginStop(req) + case "VirtualMachineInstancesClient.BeginUpdate": + resp, err = v.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (v *VirtualMachineInstancesServerTransport) dispatchBeginCreateCheckpoint(req *http.Request) (*http.Response, error) { + if v.srv.BeginCreateCheckpoint == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateCheckpoint not implemented")} + } + beginCreateCheckpoint := v.beginCreateCheckpoint.get(req) + if beginCreateCheckpoint == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachineInstances/default/createCheckpoint` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armscvmm.VirtualMachineCreateCheckpoint](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginCreateCheckpoint(req.Context(), resourceURIParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateCheckpoint = &respr + v.beginCreateCheckpoint.add(req, beginCreateCheckpoint) + } + + resp, err := server.PollerResponderNext(beginCreateCheckpoint, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + v.beginCreateCheckpoint.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateCheckpoint) { + v.beginCreateCheckpoint.remove(req) + } + + return resp, nil +} + +func (v *VirtualMachineInstancesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if v.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := v.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachineInstances/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armscvmm.VirtualMachineInstance](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginCreateOrUpdate(req.Context(), resourceURIParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + v.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + v.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + v.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (v *VirtualMachineInstancesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if v.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := v.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachineInstances/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + forceUnescaped, err := url.QueryUnescape(qp.Get("force")) + if err != nil { + return nil, err + } + forceParam := getOptional(armscvmm.ForceDelete(forceUnescaped)) + deleteFromHostUnescaped, err := url.QueryUnescape(qp.Get("deleteFromHost")) + if err != nil { + return nil, err + } + deleteFromHostParam := getOptional(armscvmm.DeleteFromHost(deleteFromHostUnescaped)) + var options *armscvmm.VirtualMachineInstancesClientBeginDeleteOptions + if forceParam != nil || deleteFromHostParam != nil { + options = &armscvmm.VirtualMachineInstancesClientBeginDeleteOptions{ + Force: forceParam, + DeleteFromHost: deleteFromHostParam, + } + } + respr, errRespr := v.srv.BeginDelete(req.Context(), resourceURIParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + v.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + v.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + v.beginDelete.remove(req) + } + + return resp, nil +} + +func (v *VirtualMachineInstancesServerTransport) dispatchBeginDeleteCheckpoint(req *http.Request) (*http.Response, error) { + if v.srv.BeginDeleteCheckpoint == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDeleteCheckpoint not implemented")} + } + beginDeleteCheckpoint := v.beginDeleteCheckpoint.get(req) + if beginDeleteCheckpoint == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachineInstances/default/deleteCheckpoint` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armscvmm.VirtualMachineDeleteCheckpoint](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginDeleteCheckpoint(req.Context(), resourceURIParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDeleteCheckpoint = &respr + v.beginDeleteCheckpoint.add(req, beginDeleteCheckpoint) + } + + resp, err := server.PollerResponderNext(beginDeleteCheckpoint, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + v.beginDeleteCheckpoint.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDeleteCheckpoint) { + v.beginDeleteCheckpoint.remove(req) + } + + return resp, nil +} + +func (v *VirtualMachineInstancesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if v.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachineInstances/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.Get(req.Context(), resourceURIParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).VirtualMachineInstance, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (v *VirtualMachineInstancesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if v.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := v.newListPager.get(req) + if newListPager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachineInstances` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + resp := v.srv.NewListPager(resourceURIParam, nil) + newListPager = &resp + v.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armscvmm.VirtualMachineInstancesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + v.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + v.newListPager.remove(req) + } + return resp, nil +} + +func (v *VirtualMachineInstancesServerTransport) dispatchBeginRestart(req *http.Request) (*http.Response, error) { + if v.srv.BeginRestart == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginRestart not implemented")} + } + beginRestart := v.beginRestart.get(req) + if beginRestart == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachineInstances/default/restart` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginRestart(req.Context(), resourceURIParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginRestart = &respr + v.beginRestart.add(req, beginRestart) + } + + resp, err := server.PollerResponderNext(beginRestart, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + v.beginRestart.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginRestart) { + v.beginRestart.remove(req) + } + + return resp, nil +} + +func (v *VirtualMachineInstancesServerTransport) dispatchBeginRestoreCheckpoint(req *http.Request) (*http.Response, error) { + if v.srv.BeginRestoreCheckpoint == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginRestoreCheckpoint not implemented")} + } + beginRestoreCheckpoint := v.beginRestoreCheckpoint.get(req) + if beginRestoreCheckpoint == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachineInstances/default/restoreCheckpoint` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armscvmm.VirtualMachineRestoreCheckpoint](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginRestoreCheckpoint(req.Context(), resourceURIParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginRestoreCheckpoint = &respr + v.beginRestoreCheckpoint.add(req, beginRestoreCheckpoint) + } + + resp, err := server.PollerResponderNext(beginRestoreCheckpoint, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + v.beginRestoreCheckpoint.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginRestoreCheckpoint) { + v.beginRestoreCheckpoint.remove(req) + } + + return resp, nil +} + +func (v *VirtualMachineInstancesServerTransport) dispatchBeginStart(req *http.Request) (*http.Response, error) { + if v.srv.BeginStart == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginStart not implemented")} + } + beginStart := v.beginStart.get(req) + if beginStart == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachineInstances/default/start` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginStart(req.Context(), resourceURIParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginStart = &respr + v.beginStart.add(req, beginStart) + } + + resp, err := server.PollerResponderNext(beginStart, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + v.beginStart.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginStart) { + v.beginStart.remove(req) + } + + return resp, nil +} + +func (v *VirtualMachineInstancesServerTransport) dispatchBeginStop(req *http.Request) (*http.Response, error) { + if v.srv.BeginStop == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginStop not implemented")} + } + beginStop := v.beginStop.get(req) + if beginStop == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachineInstances/default/stop` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armscvmm.StopVirtualMachineOptions](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginStop(req.Context(), resourceURIParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginStop = &respr + v.beginStop.add(req, beginStop) + } + + resp, err := server.PollerResponderNext(beginStop, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + v.beginStop.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginStop) { + v.beginStop.remove(req) + } + + return resp, nil +} + +func (v *VirtualMachineInstancesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if v.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := v.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachineInstances/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armscvmm.VirtualMachineInstanceUpdate](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginUpdate(req.Context(), resourceURIParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + v.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + v.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + v.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/fake/virtualmachines_server.go b/sdk/resourcemanager/scvmm/armscvmm/fake/virtualmachines_server.go deleted file mode 100644 index deb5b2a95c29..000000000000 --- a/sdk/resourcemanager/scvmm/armscvmm/fake/virtualmachines_server.go +++ /dev/null @@ -1,731 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/scvmm/armscvmm" - "net/http" - "net/url" - "reflect" - "regexp" - "strconv" -) - -// VirtualMachinesServer is a fake server for instances of the armscvmm.VirtualMachinesClient type. -type VirtualMachinesServer struct { - // BeginCreateCheckpoint is the fake for method VirtualMachinesClient.BeginCreateCheckpoint - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginCreateCheckpoint func(ctx context.Context, resourceGroupName string, virtualMachineName string, options *armscvmm.VirtualMachinesClientBeginCreateCheckpointOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachinesClientCreateCheckpointResponse], errResp azfake.ErrorResponder) - - // BeginCreateOrUpdate is the fake for method VirtualMachinesClient.BeginCreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, virtualMachineName string, body armscvmm.VirtualMachine, options *armscvmm.VirtualMachinesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachinesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - - // BeginDelete is the fake for method VirtualMachinesClient.BeginDelete - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent - BeginDelete func(ctx context.Context, resourceGroupName string, virtualMachineName string, options *armscvmm.VirtualMachinesClientBeginDeleteOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachinesClientDeleteResponse], errResp azfake.ErrorResponder) - - // BeginDeleteCheckpoint is the fake for method VirtualMachinesClient.BeginDeleteCheckpoint - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginDeleteCheckpoint func(ctx context.Context, resourceGroupName string, virtualMachineName string, options *armscvmm.VirtualMachinesClientBeginDeleteCheckpointOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachinesClientDeleteCheckpointResponse], errResp azfake.ErrorResponder) - - // Get is the fake for method VirtualMachinesClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, resourceGroupName string, virtualMachineName string, options *armscvmm.VirtualMachinesClientGetOptions) (resp azfake.Responder[armscvmm.VirtualMachinesClientGetResponse], errResp azfake.ErrorResponder) - - // NewListByResourceGroupPager is the fake for method VirtualMachinesClient.NewListByResourceGroupPager - // HTTP status codes to indicate success: http.StatusOK - NewListByResourceGroupPager func(resourceGroupName string, options *armscvmm.VirtualMachinesClientListByResourceGroupOptions) (resp azfake.PagerResponder[armscvmm.VirtualMachinesClientListByResourceGroupResponse]) - - // NewListBySubscriptionPager is the fake for method VirtualMachinesClient.NewListBySubscriptionPager - // HTTP status codes to indicate success: http.StatusOK - NewListBySubscriptionPager func(options *armscvmm.VirtualMachinesClientListBySubscriptionOptions) (resp azfake.PagerResponder[armscvmm.VirtualMachinesClientListBySubscriptionResponse]) - - // BeginRestart is the fake for method VirtualMachinesClient.BeginRestart - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginRestart func(ctx context.Context, resourceGroupName string, virtualMachineName string, options *armscvmm.VirtualMachinesClientBeginRestartOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachinesClientRestartResponse], errResp azfake.ErrorResponder) - - // BeginRestoreCheckpoint is the fake for method VirtualMachinesClient.BeginRestoreCheckpoint - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginRestoreCheckpoint func(ctx context.Context, resourceGroupName string, virtualMachineName string, options *armscvmm.VirtualMachinesClientBeginRestoreCheckpointOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachinesClientRestoreCheckpointResponse], errResp azfake.ErrorResponder) - - // BeginStart is the fake for method VirtualMachinesClient.BeginStart - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginStart func(ctx context.Context, resourceGroupName string, virtualMachineName string, options *armscvmm.VirtualMachinesClientBeginStartOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachinesClientStartResponse], errResp azfake.ErrorResponder) - - // BeginStop is the fake for method VirtualMachinesClient.BeginStop - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginStop func(ctx context.Context, resourceGroupName string, virtualMachineName string, options *armscvmm.VirtualMachinesClientBeginStopOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachinesClientStopResponse], errResp azfake.ErrorResponder) - - // BeginUpdate is the fake for method VirtualMachinesClient.BeginUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted - BeginUpdate func(ctx context.Context, resourceGroupName string, virtualMachineName string, body armscvmm.VirtualMachineUpdate, options *armscvmm.VirtualMachinesClientBeginUpdateOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachinesClientUpdateResponse], errResp azfake.ErrorResponder) -} - -// NewVirtualMachinesServerTransport creates a new instance of VirtualMachinesServerTransport with the provided implementation. -// The returned VirtualMachinesServerTransport instance is connected to an instance of armscvmm.VirtualMachinesClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewVirtualMachinesServerTransport(srv *VirtualMachinesServer) *VirtualMachinesServerTransport { - return &VirtualMachinesServerTransport{ - srv: srv, - beginCreateCheckpoint: newTracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientCreateCheckpointResponse]](), - beginCreateOrUpdate: newTracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientCreateOrUpdateResponse]](), - beginDelete: newTracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientDeleteResponse]](), - beginDeleteCheckpoint: newTracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientDeleteCheckpointResponse]](), - newListByResourceGroupPager: newTracker[azfake.PagerResponder[armscvmm.VirtualMachinesClientListByResourceGroupResponse]](), - newListBySubscriptionPager: newTracker[azfake.PagerResponder[armscvmm.VirtualMachinesClientListBySubscriptionResponse]](), - beginRestart: newTracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientRestartResponse]](), - beginRestoreCheckpoint: newTracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientRestoreCheckpointResponse]](), - beginStart: newTracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientStartResponse]](), - beginStop: newTracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientStopResponse]](), - beginUpdate: newTracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientUpdateResponse]](), - } -} - -// VirtualMachinesServerTransport connects instances of armscvmm.VirtualMachinesClient to instances of VirtualMachinesServer. -// Don't use this type directly, use NewVirtualMachinesServerTransport instead. -type VirtualMachinesServerTransport struct { - srv *VirtualMachinesServer - beginCreateCheckpoint *tracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientCreateCheckpointResponse]] - beginCreateOrUpdate *tracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientCreateOrUpdateResponse]] - beginDelete *tracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientDeleteResponse]] - beginDeleteCheckpoint *tracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientDeleteCheckpointResponse]] - newListByResourceGroupPager *tracker[azfake.PagerResponder[armscvmm.VirtualMachinesClientListByResourceGroupResponse]] - newListBySubscriptionPager *tracker[azfake.PagerResponder[armscvmm.VirtualMachinesClientListBySubscriptionResponse]] - beginRestart *tracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientRestartResponse]] - beginRestoreCheckpoint *tracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientRestoreCheckpointResponse]] - beginStart *tracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientStartResponse]] - beginStop *tracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientStopResponse]] - beginUpdate *tracker[azfake.PollerResponder[armscvmm.VirtualMachinesClientUpdateResponse]] -} - -// Do implements the policy.Transporter interface for VirtualMachinesServerTransport. -func (v *VirtualMachinesServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - var resp *http.Response - var err error - - switch method { - case "VirtualMachinesClient.BeginCreateCheckpoint": - resp, err = v.dispatchBeginCreateCheckpoint(req) - case "VirtualMachinesClient.BeginCreateOrUpdate": - resp, err = v.dispatchBeginCreateOrUpdate(req) - case "VirtualMachinesClient.BeginDelete": - resp, err = v.dispatchBeginDelete(req) - case "VirtualMachinesClient.BeginDeleteCheckpoint": - resp, err = v.dispatchBeginDeleteCheckpoint(req) - case "VirtualMachinesClient.Get": - resp, err = v.dispatchGet(req) - case "VirtualMachinesClient.NewListByResourceGroupPager": - resp, err = v.dispatchNewListByResourceGroupPager(req) - case "VirtualMachinesClient.NewListBySubscriptionPager": - resp, err = v.dispatchNewListBySubscriptionPager(req) - case "VirtualMachinesClient.BeginRestart": - resp, err = v.dispatchBeginRestart(req) - case "VirtualMachinesClient.BeginRestoreCheckpoint": - resp, err = v.dispatchBeginRestoreCheckpoint(req) - case "VirtualMachinesClient.BeginStart": - resp, err = v.dispatchBeginStart(req) - case "VirtualMachinesClient.BeginStop": - resp, err = v.dispatchBeginStop(req) - case "VirtualMachinesClient.BeginUpdate": - resp, err = v.dispatchBeginUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (v *VirtualMachinesServerTransport) dispatchBeginCreateCheckpoint(req *http.Request) (*http.Response, error) { - if v.srv.BeginCreateCheckpoint == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginCreateCheckpoint not implemented")} - } - beginCreateCheckpoint := v.beginCreateCheckpoint.get(req) - if beginCreateCheckpoint == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/createCheckpoint` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armscvmm.VirtualMachineCreateCheckpoint](req) - if err != nil { - return nil, err - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - virtualMachineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineName")]) - if err != nil { - return nil, err - } - var options *armscvmm.VirtualMachinesClientBeginCreateCheckpointOptions - if !reflect.ValueOf(body).IsZero() { - options = &armscvmm.VirtualMachinesClientBeginCreateCheckpointOptions{ - Body: &body, - } - } - respr, errRespr := v.srv.BeginCreateCheckpoint(req.Context(), resourceGroupNameParam, virtualMachineNameParam, options) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - beginCreateCheckpoint = &respr - v.beginCreateCheckpoint.add(req, beginCreateCheckpoint) - } - - resp, err := server.PollerResponderNext(beginCreateCheckpoint, req) - if err != nil { - return nil, err - } - - if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - v.beginCreateCheckpoint.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} - } - if !server.PollerResponderMore(beginCreateCheckpoint) { - v.beginCreateCheckpoint.remove(req) - } - - return resp, nil -} - -func (v *VirtualMachinesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { - if v.srv.BeginCreateOrUpdate == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} - } - beginCreateOrUpdate := v.beginCreateOrUpdate.get(req) - if beginCreateOrUpdate == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armscvmm.VirtualMachine](req) - if err != nil { - return nil, err - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - virtualMachineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, virtualMachineNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - beginCreateOrUpdate = &respr - v.beginCreateOrUpdate.add(req, beginCreateOrUpdate) - } - - resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) - if err != nil { - return nil, err - } - - if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { - v.beginCreateOrUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} - } - if !server.PollerResponderMore(beginCreateOrUpdate) { - v.beginCreateOrUpdate.remove(req) - } - - return resp, nil -} - -func (v *VirtualMachinesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { - if v.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} - } - beginDelete := v.beginDelete.get(req) - if beginDelete == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - qp := req.URL.Query() - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - virtualMachineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineName")]) - if err != nil { - return nil, err - } - retainUnescaped, err := url.QueryUnescape(qp.Get("retain")) - if err != nil { - return nil, err - } - retainParam, err := parseOptional(retainUnescaped, strconv.ParseBool) - if err != nil { - return nil, err - } - forceUnescaped, err := url.QueryUnescape(qp.Get("force")) - if err != nil { - return nil, err - } - forceParam, err := parseOptional(forceUnescaped, strconv.ParseBool) - if err != nil { - return nil, err - } - var options *armscvmm.VirtualMachinesClientBeginDeleteOptions - if retainParam != nil || forceParam != nil { - options = &armscvmm.VirtualMachinesClientBeginDeleteOptions{ - Retain: retainParam, - Force: forceParam, - } - } - respr, errRespr := v.srv.BeginDelete(req.Context(), resourceGroupNameParam, virtualMachineNameParam, options) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - beginDelete = &respr - v.beginDelete.add(req, beginDelete) - } - - resp, err := server.PollerResponderNext(beginDelete, req) - if err != nil { - return nil, err - } - - if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { - v.beginDelete.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} - } - if !server.PollerResponderMore(beginDelete) { - v.beginDelete.remove(req) - } - - return resp, nil -} - -func (v *VirtualMachinesServerTransport) dispatchBeginDeleteCheckpoint(req *http.Request) (*http.Response, error) { - if v.srv.BeginDeleteCheckpoint == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginDeleteCheckpoint not implemented")} - } - beginDeleteCheckpoint := v.beginDeleteCheckpoint.get(req) - if beginDeleteCheckpoint == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deleteCheckpoint` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armscvmm.VirtualMachineDeleteCheckpoint](req) - if err != nil { - return nil, err - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - virtualMachineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineName")]) - if err != nil { - return nil, err - } - var options *armscvmm.VirtualMachinesClientBeginDeleteCheckpointOptions - if !reflect.ValueOf(body).IsZero() { - options = &armscvmm.VirtualMachinesClientBeginDeleteCheckpointOptions{ - Body: &body, - } - } - respr, errRespr := v.srv.BeginDeleteCheckpoint(req.Context(), resourceGroupNameParam, virtualMachineNameParam, options) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - beginDeleteCheckpoint = &respr - v.beginDeleteCheckpoint.add(req, beginDeleteCheckpoint) - } - - resp, err := server.PollerResponderNext(beginDeleteCheckpoint, req) - if err != nil { - return nil, err - } - - if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - v.beginDeleteCheckpoint.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} - } - if !server.PollerResponderMore(beginDeleteCheckpoint) { - v.beginDeleteCheckpoint.remove(req) - } - - return resp, nil -} - -func (v *VirtualMachinesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if v.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - virtualMachineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.Get(req.Context(), resourceGroupNameParam, virtualMachineNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).VirtualMachine, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VirtualMachinesServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { - if v.srv.NewListByResourceGroupPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} - } - newListByResourceGroupPager := v.newListByResourceGroupPager.get(req) - if newListByResourceGroupPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachines` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - resp := v.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) - newListByResourceGroupPager = &resp - v.newListByResourceGroupPager.add(req, newListByResourceGroupPager) - server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armscvmm.VirtualMachinesClientListByResourceGroupResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - v.newListByResourceGroupPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListByResourceGroupPager) { - v.newListByResourceGroupPager.remove(req) - } - return resp, nil -} - -func (v *VirtualMachinesServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { - if v.srv.NewListBySubscriptionPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} - } - newListBySubscriptionPager := v.newListBySubscriptionPager.get(req) - if newListBySubscriptionPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachines` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resp := v.srv.NewListBySubscriptionPager(nil) - newListBySubscriptionPager = &resp - v.newListBySubscriptionPager.add(req, newListBySubscriptionPager) - server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armscvmm.VirtualMachinesClientListBySubscriptionResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - v.newListBySubscriptionPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListBySubscriptionPager) { - v.newListBySubscriptionPager.remove(req) - } - return resp, nil -} - -func (v *VirtualMachinesServerTransport) dispatchBeginRestart(req *http.Request) (*http.Response, error) { - if v.srv.BeginRestart == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginRestart not implemented")} - } - beginRestart := v.beginRestart.get(req) - if beginRestart == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/restart` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - virtualMachineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.BeginRestart(req.Context(), resourceGroupNameParam, virtualMachineNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - beginRestart = &respr - v.beginRestart.add(req, beginRestart) - } - - resp, err := server.PollerResponderNext(beginRestart, req) - if err != nil { - return nil, err - } - - if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - v.beginRestart.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} - } - if !server.PollerResponderMore(beginRestart) { - v.beginRestart.remove(req) - } - - return resp, nil -} - -func (v *VirtualMachinesServerTransport) dispatchBeginRestoreCheckpoint(req *http.Request) (*http.Response, error) { - if v.srv.BeginRestoreCheckpoint == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginRestoreCheckpoint not implemented")} - } - beginRestoreCheckpoint := v.beginRestoreCheckpoint.get(req) - if beginRestoreCheckpoint == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/restoreCheckpoint` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armscvmm.VirtualMachineRestoreCheckpoint](req) - if err != nil { - return nil, err - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - virtualMachineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineName")]) - if err != nil { - return nil, err - } - var options *armscvmm.VirtualMachinesClientBeginRestoreCheckpointOptions - if !reflect.ValueOf(body).IsZero() { - options = &armscvmm.VirtualMachinesClientBeginRestoreCheckpointOptions{ - Body: &body, - } - } - respr, errRespr := v.srv.BeginRestoreCheckpoint(req.Context(), resourceGroupNameParam, virtualMachineNameParam, options) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - beginRestoreCheckpoint = &respr - v.beginRestoreCheckpoint.add(req, beginRestoreCheckpoint) - } - - resp, err := server.PollerResponderNext(beginRestoreCheckpoint, req) - if err != nil { - return nil, err - } - - if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - v.beginRestoreCheckpoint.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} - } - if !server.PollerResponderMore(beginRestoreCheckpoint) { - v.beginRestoreCheckpoint.remove(req) - } - - return resp, nil -} - -func (v *VirtualMachinesServerTransport) dispatchBeginStart(req *http.Request) (*http.Response, error) { - if v.srv.BeginStart == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginStart not implemented")} - } - beginStart := v.beginStart.get(req) - if beginStart == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/start` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - virtualMachineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.BeginStart(req.Context(), resourceGroupNameParam, virtualMachineNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - beginStart = &respr - v.beginStart.add(req, beginStart) - } - - resp, err := server.PollerResponderNext(beginStart, req) - if err != nil { - return nil, err - } - - if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - v.beginStart.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} - } - if !server.PollerResponderMore(beginStart) { - v.beginStart.remove(req) - } - - return resp, nil -} - -func (v *VirtualMachinesServerTransport) dispatchBeginStop(req *http.Request) (*http.Response, error) { - if v.srv.BeginStop == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginStop not implemented")} - } - beginStop := v.beginStop.get(req) - if beginStop == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/stop` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armscvmm.StopVirtualMachineOptions](req) - if err != nil { - return nil, err - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - virtualMachineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineName")]) - if err != nil { - return nil, err - } - var options *armscvmm.VirtualMachinesClientBeginStopOptions - if !reflect.ValueOf(body).IsZero() { - options = &armscvmm.VirtualMachinesClientBeginStopOptions{ - Body: &body, - } - } - respr, errRespr := v.srv.BeginStop(req.Context(), resourceGroupNameParam, virtualMachineNameParam, options) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - beginStop = &respr - v.beginStop.add(req, beginStop) - } - - resp, err := server.PollerResponderNext(beginStop, req) - if err != nil { - return nil, err - } - - if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - v.beginStop.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} - } - if !server.PollerResponderMore(beginStop) { - v.beginStop.remove(req) - } - - return resp, nil -} - -func (v *VirtualMachinesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { - if v.srv.BeginUpdate == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} - } - beginUpdate := v.beginUpdate.get(req) - if beginUpdate == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armscvmm.VirtualMachineUpdate](req) - if err != nil { - return nil, err - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - virtualMachineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.BeginUpdate(req.Context(), resourceGroupNameParam, virtualMachineNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - beginUpdate = &respr - v.beginUpdate.add(req, beginUpdate) - } - - resp, err := server.PollerResponderNext(beginUpdate, req) - if err != nil { - return nil, err - } - - if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { - v.beginUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} - } - if !server.PollerResponderMore(beginUpdate) { - v.beginUpdate.remove(req) - } - - return resp, nil -} diff --git a/sdk/resourcemanager/scvmm/armscvmm/fake/virtualmachinetemplates_server.go b/sdk/resourcemanager/scvmm/armscvmm/fake/virtualmachinetemplates_server.go index 4e533b81acd0..9a4308e8cbc8 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/fake/virtualmachinetemplates_server.go +++ b/sdk/resourcemanager/scvmm/armscvmm/fake/virtualmachinetemplates_server.go @@ -20,17 +20,16 @@ import ( "net/http" "net/url" "regexp" - "strconv" ) // VirtualMachineTemplatesServer is a fake server for instances of the armscvmm.VirtualMachineTemplatesClient type. type VirtualMachineTemplatesServer struct { // BeginCreateOrUpdate is the fake for method VirtualMachineTemplatesClient.BeginCreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body armscvmm.VirtualMachineTemplate, options *armscvmm.VirtualMachineTemplatesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachineTemplatesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, resource armscvmm.VirtualMachineTemplate, options *armscvmm.VirtualMachineTemplatesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachineTemplatesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method VirtualMachineTemplatesClient.BeginDelete - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent BeginDelete func(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, options *armscvmm.VirtualMachineTemplatesClientBeginDeleteOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachineTemplatesClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method VirtualMachineTemplatesClient.Get @@ -46,8 +45,8 @@ type VirtualMachineTemplatesServer struct { NewListBySubscriptionPager func(options *armscvmm.VirtualMachineTemplatesClientListBySubscriptionOptions) (resp azfake.PagerResponder[armscvmm.VirtualMachineTemplatesClientListBySubscriptionResponse]) // BeginUpdate is the fake for method VirtualMachineTemplatesClient.BeginUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted - BeginUpdate func(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body armscvmm.ResourcePatch, options *armscvmm.VirtualMachineTemplatesClientBeginUpdateOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachineTemplatesClientUpdateResponse], errResp azfake.ErrorResponder) + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, properties armscvmm.VirtualMachineTemplateTagsUpdate, options *armscvmm.VirtualMachineTemplatesClientBeginUpdateOptions) (resp azfake.PollerResponder[armscvmm.VirtualMachineTemplatesClientUpdateResponse], errResp azfake.ErrorResponder) } // NewVirtualMachineTemplatesServerTransport creates a new instance of VirtualMachineTemplatesServerTransport with the provided implementation. @@ -175,15 +174,12 @@ func (v *VirtualMachineTemplatesServerTransport) dispatchBeginDelete(req *http.R if err != nil { return nil, err } - virtualMachineTemplateNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineTemplateName")]) - if err != nil { - return nil, err - } forceUnescaped, err := url.QueryUnescape(qp.Get("force")) if err != nil { return nil, err } - forceParam, err := parseOptional(forceUnescaped, strconv.ParseBool) + forceParam := getOptional(armscvmm.ForceDelete(forceUnescaped)) + virtualMachineTemplateNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineTemplateName")]) if err != nil { return nil, err } @@ -206,9 +202,9 @@ func (v *VirtualMachineTemplatesServerTransport) dispatchBeginDelete(req *http.R return nil, err } - if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { v.beginDelete.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDelete) { v.beginDelete.remove(req) @@ -332,7 +328,7 @@ func (v *VirtualMachineTemplatesServerTransport) dispatchBeginUpdate(req *http.R if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armscvmm.ResourcePatch](req) + body, err := server.UnmarshalRequestAsJSON[armscvmm.VirtualMachineTemplateTagsUpdate](req) if err != nil { return nil, err } @@ -357,9 +353,9 @@ func (v *VirtualMachineTemplatesServerTransport) dispatchBeginUpdate(req *http.R return nil, err } - if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { v.beginUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginUpdate) { v.beginUpdate.remove(req) diff --git a/sdk/resourcemanager/scvmm/armscvmm/fake/virtualnetworks_server.go b/sdk/resourcemanager/scvmm/armscvmm/fake/virtualnetworks_server.go index 663cec429613..33c8a6cb93c1 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/fake/virtualnetworks_server.go +++ b/sdk/resourcemanager/scvmm/armscvmm/fake/virtualnetworks_server.go @@ -20,17 +20,16 @@ import ( "net/http" "net/url" "regexp" - "strconv" ) // VirtualNetworksServer is a fake server for instances of the armscvmm.VirtualNetworksClient type. type VirtualNetworksServer struct { // BeginCreateOrUpdate is the fake for method VirtualNetworksClient.BeginCreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, virtualNetworkName string, body armscvmm.VirtualNetwork, options *armscvmm.VirtualNetworksClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armscvmm.VirtualNetworksClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, virtualNetworkName string, resource armscvmm.VirtualNetwork, options *armscvmm.VirtualNetworksClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armscvmm.VirtualNetworksClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method VirtualNetworksClient.BeginDelete - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent BeginDelete func(ctx context.Context, resourceGroupName string, virtualNetworkName string, options *armscvmm.VirtualNetworksClientBeginDeleteOptions) (resp azfake.PollerResponder[armscvmm.VirtualNetworksClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method VirtualNetworksClient.Get @@ -46,8 +45,8 @@ type VirtualNetworksServer struct { NewListBySubscriptionPager func(options *armscvmm.VirtualNetworksClientListBySubscriptionOptions) (resp azfake.PagerResponder[armscvmm.VirtualNetworksClientListBySubscriptionResponse]) // BeginUpdate is the fake for method VirtualNetworksClient.BeginUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted - BeginUpdate func(ctx context.Context, resourceGroupName string, virtualNetworkName string, body armscvmm.ResourcePatch, options *armscvmm.VirtualNetworksClientBeginUpdateOptions) (resp azfake.PollerResponder[armscvmm.VirtualNetworksClientUpdateResponse], errResp azfake.ErrorResponder) + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, virtualNetworkName string, properties armscvmm.VirtualNetworkTagsUpdate, options *armscvmm.VirtualNetworksClientBeginUpdateOptions) (resp azfake.PollerResponder[armscvmm.VirtualNetworksClientUpdateResponse], errResp azfake.ErrorResponder) } // NewVirtualNetworksServerTransport creates a new instance of VirtualNetworksServerTransport with the provided implementation. @@ -175,15 +174,12 @@ func (v *VirtualNetworksServerTransport) dispatchBeginDelete(req *http.Request) if err != nil { return nil, err } - virtualNetworkNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualNetworkName")]) - if err != nil { - return nil, err - } forceUnescaped, err := url.QueryUnescape(qp.Get("force")) if err != nil { return nil, err } - forceParam, err := parseOptional(forceUnescaped, strconv.ParseBool) + forceParam := getOptional(armscvmm.ForceDelete(forceUnescaped)) + virtualNetworkNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualNetworkName")]) if err != nil { return nil, err } @@ -206,9 +202,9 @@ func (v *VirtualNetworksServerTransport) dispatchBeginDelete(req *http.Request) return nil, err } - if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { v.beginDelete.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDelete) { v.beginDelete.remove(req) @@ -332,7 +328,7 @@ func (v *VirtualNetworksServerTransport) dispatchBeginUpdate(req *http.Request) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armscvmm.ResourcePatch](req) + body, err := server.UnmarshalRequestAsJSON[armscvmm.VirtualNetworkTagsUpdate](req) if err != nil { return nil, err } @@ -357,9 +353,9 @@ func (v *VirtualNetworksServerTransport) dispatchBeginUpdate(req *http.Request) return nil, err } - if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { v.beginUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginUpdate) { v.beginUpdate.remove(req) diff --git a/sdk/resourcemanager/scvmm/armscvmm/fake/vminstancehybrididentitymetadatas_server.go b/sdk/resourcemanager/scvmm/armscvmm/fake/vminstancehybrididentitymetadatas_server.go new file mode 100644 index 000000000000..5b8d55a3702d --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/fake/vminstancehybrididentitymetadatas_server.go @@ -0,0 +1,144 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/scvmm/armscvmm" + "net/http" + "net/url" + "regexp" +) + +// VMInstanceHybridIdentityMetadatasServer is a fake server for instances of the armscvmm.VMInstanceHybridIdentityMetadatasClient type. +type VMInstanceHybridIdentityMetadatasServer struct { + // Get is the fake for method VMInstanceHybridIdentityMetadatasClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceURI string, options *armscvmm.VMInstanceHybridIdentityMetadatasClientGetOptions) (resp azfake.Responder[armscvmm.VMInstanceHybridIdentityMetadatasClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByVirtualMachineInstancePager is the fake for method VMInstanceHybridIdentityMetadatasClient.NewListByVirtualMachineInstancePager + // HTTP status codes to indicate success: http.StatusOK + NewListByVirtualMachineInstancePager func(resourceURI string, options *armscvmm.VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceOptions) (resp azfake.PagerResponder[armscvmm.VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceResponse]) +} + +// NewVMInstanceHybridIdentityMetadatasServerTransport creates a new instance of VMInstanceHybridIdentityMetadatasServerTransport with the provided implementation. +// The returned VMInstanceHybridIdentityMetadatasServerTransport instance is connected to an instance of armscvmm.VMInstanceHybridIdentityMetadatasClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewVMInstanceHybridIdentityMetadatasServerTransport(srv *VMInstanceHybridIdentityMetadatasServer) *VMInstanceHybridIdentityMetadatasServerTransport { + return &VMInstanceHybridIdentityMetadatasServerTransport{ + srv: srv, + newListByVirtualMachineInstancePager: newTracker[azfake.PagerResponder[armscvmm.VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceResponse]](), + } +} + +// VMInstanceHybridIdentityMetadatasServerTransport connects instances of armscvmm.VMInstanceHybridIdentityMetadatasClient to instances of VMInstanceHybridIdentityMetadatasServer. +// Don't use this type directly, use NewVMInstanceHybridIdentityMetadatasServerTransport instead. +type VMInstanceHybridIdentityMetadatasServerTransport struct { + srv *VMInstanceHybridIdentityMetadatasServer + newListByVirtualMachineInstancePager *tracker[azfake.PagerResponder[armscvmm.VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceResponse]] +} + +// Do implements the policy.Transporter interface for VMInstanceHybridIdentityMetadatasServerTransport. +func (v *VMInstanceHybridIdentityMetadatasServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "VMInstanceHybridIdentityMetadatasClient.Get": + resp, err = v.dispatchGet(req) + case "VMInstanceHybridIdentityMetadatasClient.NewListByVirtualMachineInstancePager": + resp, err = v.dispatchNewListByVirtualMachineInstancePager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (v *VMInstanceHybridIdentityMetadatasServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if v.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachineInstances/default/hybridIdentityMetadata/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.Get(req.Context(), resourceURIParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).VMInstanceHybridIdentityMetadata, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (v *VMInstanceHybridIdentityMetadatasServerTransport) dispatchNewListByVirtualMachineInstancePager(req *http.Request) (*http.Response, error) { + if v.srv.NewListByVirtualMachineInstancePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByVirtualMachineInstancePager not implemented")} + } + newListByVirtualMachineInstancePager := v.newListByVirtualMachineInstancePager.get(req) + if newListByVirtualMachineInstancePager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ScVmm/virtualMachineInstances/default/hybridIdentityMetadata` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + resp := v.srv.NewListByVirtualMachineInstancePager(resourceURIParam, nil) + newListByVirtualMachineInstancePager = &resp + v.newListByVirtualMachineInstancePager.add(req, newListByVirtualMachineInstancePager) + server.PagerResponderInjectNextLinks(newListByVirtualMachineInstancePager, req, func(page *armscvmm.VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByVirtualMachineInstancePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + v.newListByVirtualMachineInstancePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByVirtualMachineInstancePager) { + v.newListByVirtualMachineInstancePager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/fake/vmmservers_server.go b/sdk/resourcemanager/scvmm/armscvmm/fake/vmmservers_server.go index 7debb3970771..1f21f887f115 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/fake/vmmservers_server.go +++ b/sdk/resourcemanager/scvmm/armscvmm/fake/vmmservers_server.go @@ -20,17 +20,16 @@ import ( "net/http" "net/url" "regexp" - "strconv" ) // VmmServersServer is a fake server for instances of the armscvmm.VmmServersClient type. type VmmServersServer struct { // BeginCreateOrUpdate is the fake for method VmmServersClient.BeginCreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, vmmServerName string, body armscvmm.VMMServer, options *armscvmm.VmmServersClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armscvmm.VmmServersClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, vmmServerName string, resource armscvmm.VmmServer, options *armscvmm.VmmServersClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armscvmm.VmmServersClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method VmmServersClient.BeginDelete - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent BeginDelete func(ctx context.Context, resourceGroupName string, vmmServerName string, options *armscvmm.VmmServersClientBeginDeleteOptions) (resp azfake.PollerResponder[armscvmm.VmmServersClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method VmmServersClient.Get @@ -46,8 +45,8 @@ type VmmServersServer struct { NewListBySubscriptionPager func(options *armscvmm.VmmServersClientListBySubscriptionOptions) (resp azfake.PagerResponder[armscvmm.VmmServersClientListBySubscriptionResponse]) // BeginUpdate is the fake for method VmmServersClient.BeginUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted - BeginUpdate func(ctx context.Context, resourceGroupName string, vmmServerName string, body armscvmm.ResourcePatch, options *armscvmm.VmmServersClientBeginUpdateOptions) (resp azfake.PollerResponder[armscvmm.VmmServersClientUpdateResponse], errResp azfake.ErrorResponder) + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, vmmServerName string, properties armscvmm.VmmServerTagsUpdate, options *armscvmm.VmmServersClientBeginUpdateOptions) (resp azfake.PollerResponder[armscvmm.VmmServersClientUpdateResponse], errResp azfake.ErrorResponder) } // NewVmmServersServerTransport creates a new instance of VmmServersServerTransport with the provided implementation. @@ -122,7 +121,7 @@ func (v *VmmServersServerTransport) dispatchBeginCreateOrUpdate(req *http.Reques if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armscvmm.VMMServer](req) + body, err := server.UnmarshalRequestAsJSON[armscvmm.VmmServer](req) if err != nil { return nil, err } @@ -175,15 +174,12 @@ func (v *VmmServersServerTransport) dispatchBeginDelete(req *http.Request) (*htt if err != nil { return nil, err } - vmmServerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vmmServerName")]) - if err != nil { - return nil, err - } forceUnescaped, err := url.QueryUnescape(qp.Get("force")) if err != nil { return nil, err } - forceParam, err := parseOptional(forceUnescaped, strconv.ParseBool) + forceParam := getOptional(armscvmm.ForceDelete(forceUnescaped)) + vmmServerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vmmServerName")]) if err != nil { return nil, err } @@ -206,9 +202,9 @@ func (v *VmmServersServerTransport) dispatchBeginDelete(req *http.Request) (*htt return nil, err } - if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { v.beginDelete.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDelete) { v.beginDelete.remove(req) @@ -243,7 +239,7 @@ func (v *VmmServersServerTransport) dispatchGet(req *http.Request) (*http.Respon if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).VMMServer, req) + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).VmmServer, req) if err != nil { return nil, err } @@ -332,7 +328,7 @@ func (v *VmmServersServerTransport) dispatchBeginUpdate(req *http.Request) (*htt if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armscvmm.ResourcePatch](req) + body, err := server.UnmarshalRequestAsJSON[armscvmm.VmmServerTagsUpdate](req) if err != nil { return nil, err } @@ -357,9 +353,9 @@ func (v *VmmServersServerTransport) dispatchBeginUpdate(req *http.Request) (*htt return nil, err } - if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { v.beginUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginUpdate) { v.beginUpdate.remove(req) diff --git a/sdk/resourcemanager/scvmm/armscvmm/go.mod b/sdk/resourcemanager/scvmm/armscvmm/go.mod index 4b7cc6dd8101..2627976280d9 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/go.mod +++ b/sdk/resourcemanager/scvmm/armscvmm/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/scvmm/armscvmm go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.12.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.6.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.12.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.9.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.24.0 // indirect golang.org/x/net v0.26.0 // indirect - golang.org/x/sys v0.21.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/sdk/resourcemanager/scvmm/armscvmm/go.sum b/sdk/resourcemanager/scvmm/armscvmm/go.sum index e8d8068ae2d8..6b8c4a4ad083 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/go.sum +++ b/sdk/resourcemanager/scvmm/armscvmm/go.sum @@ -1,29 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.12.0 h1:1nGuui+4POelzDwI7RG56yfQJHCnKvwfMoU7VsEp+Zg= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.12.0/go.mod h1:99EvauvlcJ1U06amZiksfYz/3aFGyIhWGHVyiZXtBAI= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.6.0 h1:U2rTu3Ef+7w9FHKIAXM6ZyqF3UOWJZ12zIm8zECAFfg= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.6.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/internal v1.9.0 h1:H+U3Gk9zY56G3u872L82bk4thcsy2Gghb9ExT4Zvm1o= github.com/Azure/azure-sdk-for-go/sdk/internal v1.9.0/go.mod h1:mgrmMSgaLp9hmax62XQTd0N4aAqSE5E0DulSpVYK7vc= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= -github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.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-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/scvmm/armscvmm/guestagents_client.go b/sdk/resourcemanager/scvmm/armscvmm/guestagents_client.go new file mode 100644 index 000000000000..a19e5074b1bf --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/guestagents_client.go @@ -0,0 +1,254 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armscvmm + +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" +) + +// GuestAgentsClient contains the methods for the GuestAgents group. +// Don't use this type directly, use NewGuestAgentsClient() instead. +type GuestAgentsClient struct { + internal *arm.Client +} + +// NewGuestAgentsClient creates a new instance of GuestAgentsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewGuestAgentsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*GuestAgentsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &GuestAgentsClient{ + internal: cl, + } + return client, nil +} + +// BeginCreate - Create Or Update GuestAgent. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - resource - Resource create parameters. +// - options - GuestAgentsClientBeginCreateOptions contains the optional parameters for the GuestAgentsClient.BeginCreate method. +func (client *GuestAgentsClient) BeginCreate(ctx context.Context, resourceURI string, resource GuestAgent, options *GuestAgentsClientBeginCreateOptions) (*runtime.Poller[GuestAgentsClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceURI, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GuestAgentsClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[GuestAgentsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Create - Create Or Update GuestAgent. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-01 +func (client *GuestAgentsClient) create(ctx context.Context, resourceURI string, resource GuestAgent, options *GuestAgentsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "GuestAgentsClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCreateRequest(ctx, resourceURI, resource, 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 *GuestAgentsClient) createCreateRequest(ctx context.Context, resourceURI string, resource GuestAgent, options *GuestAgentsClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ScVmm/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", "2024-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// Delete - Implements GuestAgent DELETE method. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - options - GuestAgentsClientDeleteOptions contains the optional parameters for the GuestAgentsClient.Delete method. +func (client *GuestAgentsClient) Delete(ctx context.Context, resourceURI string, options *GuestAgentsClientDeleteOptions) (GuestAgentsClientDeleteResponse, error) { + var err error + const operationName = "GuestAgentsClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceURI, options) + if err != nil { + return GuestAgentsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return GuestAgentsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return GuestAgentsClientDeleteResponse{}, err + } + return GuestAgentsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *GuestAgentsClient) deleteCreateRequest(ctx context.Context, resourceURI string, options *GuestAgentsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ScVmm/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", "2024-06-01") + 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 2024-06-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - options - GuestAgentsClientGetOptions contains the optional parameters for the GuestAgentsClient.Get method. +func (client *GuestAgentsClient) Get(ctx context.Context, resourceURI string, options *GuestAgentsClientGetOptions) (GuestAgentsClientGetResponse, error) { + var err error + const operationName = "GuestAgentsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceURI, options) + if err != nil { + return GuestAgentsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return GuestAgentsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return GuestAgentsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *GuestAgentsClient) getCreateRequest(ctx context.Context, resourceURI string, options *GuestAgentsClientGetOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ScVmm/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", "2024-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *GuestAgentsClient) getHandleResponse(resp *http.Response) (GuestAgentsClientGetResponse, error) { + result := GuestAgentsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GuestAgent); err != nil { + return GuestAgentsClientGetResponse{}, err + } + return result, nil +} + +// NewListByVirtualMachineInstancePager - Returns the list of GuestAgent of the given vm. +// +// Generated from API version 2024-06-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - options - GuestAgentsClientListByVirtualMachineInstanceOptions contains the optional parameters for the GuestAgentsClient.NewListByVirtualMachineInstancePager +// method. +func (client *GuestAgentsClient) NewListByVirtualMachineInstancePager(resourceURI string, options *GuestAgentsClientListByVirtualMachineInstanceOptions) *runtime.Pager[GuestAgentsClientListByVirtualMachineInstanceResponse] { + return runtime.NewPager(runtime.PagingHandler[GuestAgentsClientListByVirtualMachineInstanceResponse]{ + More: func(page GuestAgentsClientListByVirtualMachineInstanceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *GuestAgentsClientListByVirtualMachineInstanceResponse) (GuestAgentsClientListByVirtualMachineInstanceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "GuestAgentsClient.NewListByVirtualMachineInstancePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByVirtualMachineInstanceCreateRequest(ctx, resourceURI, options) + }, nil) + if err != nil { + return GuestAgentsClientListByVirtualMachineInstanceResponse{}, err + } + return client.listByVirtualMachineInstanceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByVirtualMachineInstanceCreateRequest creates the ListByVirtualMachineInstance request. +func (client *GuestAgentsClient) listByVirtualMachineInstanceCreateRequest(ctx context.Context, resourceURI string, options *GuestAgentsClientListByVirtualMachineInstanceOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ScVmm/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", "2024-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByVirtualMachineInstanceHandleResponse handles the ListByVirtualMachineInstance response. +func (client *GuestAgentsClient) listByVirtualMachineInstanceHandleResponse(resp *http.Response) (GuestAgentsClientListByVirtualMachineInstanceResponse, error) { + result := GuestAgentsClientListByVirtualMachineInstanceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GuestAgentListResult); err != nil { + return GuestAgentsClientListByVirtualMachineInstanceResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/inventoryitems_client.go b/sdk/resourcemanager/scvmm/armscvmm/inventoryitems_client.go index efa0a1e327b8..c90100c46477 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/inventoryitems_client.go +++ b/sdk/resourcemanager/scvmm/armscvmm/inventoryitems_client.go @@ -28,7 +28,7 @@ type InventoryItemsClient struct { } // NewInventoryItemsClient creates a new instance of InventoryItemsClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewInventoryItemsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*InventoryItemsClient, error) { @@ -46,18 +46,19 @@ 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 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - vmmServerName - Name of the VMMServer. -// - inventoryItemName - Name of the inventoryItem. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vmmServerName - Name of the VmmServer. +// - inventoryItemResourceName - Name of the inventoryItem. +// - resource - Resource create parameters. // - options - InventoryItemsClientCreateOptions contains the optional parameters for the InventoryItemsClient.Create method. -func (client *InventoryItemsClient) Create(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemName string, options *InventoryItemsClientCreateOptions) (InventoryItemsClientCreateResponse, error) { +func (client *InventoryItemsClient) Create(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemResourceName string, resource InventoryItem, options *InventoryItemsClientCreateOptions) (InventoryItemsClientCreateResponse, error) { var err error const operationName = "InventoryItemsClient.Create" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createCreateRequest(ctx, resourceGroupName, vmmServerName, inventoryItemName, options) + req, err := client.createCreateRequest(ctx, resourceGroupName, vmmServerName, inventoryItemResourceName, resource, options) if err != nil { return InventoryItemsClientCreateResponse{}, err } @@ -65,7 +66,7 @@ func (client *InventoryItemsClient) Create(ctx context.Context, resourceGroupNam if err != nil { return InventoryItemsClientCreateResponse{}, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) return InventoryItemsClientCreateResponse{}, err } @@ -74,8 +75,8 @@ func (client *InventoryItemsClient) Create(ctx context.Context, resourceGroupNam } // createCreateRequest creates the Create request. -func (client *InventoryItemsClient) createCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemName string, options *InventoryItemsClientCreateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemName}" +func (client *InventoryItemsClient) createCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemResourceName string, resource InventoryItem, options *InventoryItemsClientCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemResourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -88,23 +89,20 @@ func (client *InventoryItemsClient) createCreateRequest(ctx context.Context, res return nil, errors.New("parameter vmmServerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vmmServerName}", url.PathEscape(vmmServerName)) - if inventoryItemName == "" { - return nil, errors.New("parameter inventoryItemName cannot be empty") + if inventoryItemResourceName == "" { + return nil, errors.New("parameter inventoryItemResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{inventoryItemName}", url.PathEscape(inventoryItemName)) + urlPath = strings.ReplaceAll(urlPath, "{inventoryItemResourceName}", url.PathEscape(inventoryItemResourceName)) 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", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") 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 + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err } return req, nil } @@ -121,18 +119,18 @@ func (client *InventoryItemsClient) createHandleResponse(resp *http.Response) (I // Delete - Deletes an inventoryItem. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - vmmServerName - Name of the VMMServer. -// - inventoryItemName - Name of the inventoryItem. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vmmServerName - Name of the VmmServer. +// - inventoryItemResourceName - Name of the inventoryItem. // - options - InventoryItemsClientDeleteOptions contains the optional parameters for the InventoryItemsClient.Delete method. -func (client *InventoryItemsClient) Delete(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemName string, options *InventoryItemsClientDeleteOptions) (InventoryItemsClientDeleteResponse, error) { +func (client *InventoryItemsClient) Delete(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemResourceName string, options *InventoryItemsClientDeleteOptions) (InventoryItemsClientDeleteResponse, error) { var err error const operationName = "InventoryItemsClient.Delete" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.deleteCreateRequest(ctx, resourceGroupName, vmmServerName, inventoryItemName, options) + req, err := client.deleteCreateRequest(ctx, resourceGroupName, vmmServerName, inventoryItemResourceName, options) if err != nil { return InventoryItemsClientDeleteResponse{}, err } @@ -148,8 +146,8 @@ func (client *InventoryItemsClient) Delete(ctx context.Context, resourceGroupNam } // deleteCreateRequest creates the Delete request. -func (client *InventoryItemsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemName string, options *InventoryItemsClientDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemName}" +func (client *InventoryItemsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemResourceName string, options *InventoryItemsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemResourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -162,16 +160,16 @@ func (client *InventoryItemsClient) deleteCreateRequest(ctx context.Context, res return nil, errors.New("parameter vmmServerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vmmServerName}", url.PathEscape(vmmServerName)) - if inventoryItemName == "" { - return nil, errors.New("parameter inventoryItemName cannot be empty") + if inventoryItemResourceName == "" { + return nil, errors.New("parameter inventoryItemResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{inventoryItemName}", url.PathEscape(inventoryItemName)) + urlPath = strings.ReplaceAll(urlPath, "{inventoryItemResourceName}", url.PathEscape(inventoryItemResourceName)) 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", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -180,18 +178,18 @@ func (client *InventoryItemsClient) deleteCreateRequest(ctx context.Context, res // Get - Shows an inventory item. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - vmmServerName - Name of the VMMServer. -// - inventoryItemName - Name of the inventoryItem. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vmmServerName - Name of the VmmServer. +// - inventoryItemResourceName - Name of the inventoryItem. // - options - InventoryItemsClientGetOptions contains the optional parameters for the InventoryItemsClient.Get method. -func (client *InventoryItemsClient) Get(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemName string, options *InventoryItemsClientGetOptions) (InventoryItemsClientGetResponse, error) { +func (client *InventoryItemsClient) Get(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemResourceName string, options *InventoryItemsClientGetOptions) (InventoryItemsClientGetResponse, error) { var err error const operationName = "InventoryItemsClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, resourceGroupName, vmmServerName, inventoryItemName, options) + req, err := client.getCreateRequest(ctx, resourceGroupName, vmmServerName, inventoryItemResourceName, options) if err != nil { return InventoryItemsClientGetResponse{}, err } @@ -208,8 +206,8 @@ func (client *InventoryItemsClient) Get(ctx context.Context, resourceGroupName s } // getCreateRequest creates the Get request. -func (client *InventoryItemsClient) getCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemName string, options *InventoryItemsClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemName}" +func (client *InventoryItemsClient) getCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, inventoryItemResourceName string, options *InventoryItemsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems/{inventoryItemResourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -222,16 +220,16 @@ func (client *InventoryItemsClient) getCreateRequest(ctx context.Context, resour return nil, errors.New("parameter vmmServerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vmmServerName}", url.PathEscape(vmmServerName)) - if inventoryItemName == "" { - return nil, errors.New("parameter inventoryItemName cannot be empty") + if inventoryItemResourceName == "" { + return nil, errors.New("parameter inventoryItemResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{inventoryItemName}", url.PathEscape(inventoryItemName)) + urlPath = strings.ReplaceAll(urlPath, "{inventoryItemResourceName}", url.PathEscape(inventoryItemResourceName)) 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", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -246,38 +244,38 @@ func (client *InventoryItemsClient) getHandleResponse(resp *http.Response) (Inve return result, nil } -// NewListByVMMServerPager - Returns the list of inventoryItems in the given VMMServer. +// NewListByVmmServerPager - Returns the list of inventoryItems in the given VmmServer. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - vmmServerName - Name of the VMMServer. -// - options - InventoryItemsClientListByVMMServerOptions contains the optional parameters for the InventoryItemsClient.NewListByVMMServerPager +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vmmServerName - Name of the VmmServer. +// - options - InventoryItemsClientListByVmmServerOptions contains the optional parameters for the InventoryItemsClient.NewListByVmmServerPager // method. -func (client *InventoryItemsClient) NewListByVMMServerPager(resourceGroupName string, vmmServerName string, options *InventoryItemsClientListByVMMServerOptions) *runtime.Pager[InventoryItemsClientListByVMMServerResponse] { - return runtime.NewPager(runtime.PagingHandler[InventoryItemsClientListByVMMServerResponse]{ - More: func(page InventoryItemsClientListByVMMServerResponse) bool { +func (client *InventoryItemsClient) NewListByVmmServerPager(resourceGroupName string, vmmServerName string, options *InventoryItemsClientListByVmmServerOptions) *runtime.Pager[InventoryItemsClientListByVmmServerResponse] { + return runtime.NewPager(runtime.PagingHandler[InventoryItemsClientListByVmmServerResponse]{ + More: func(page InventoryItemsClientListByVmmServerResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *InventoryItemsClientListByVMMServerResponse) (InventoryItemsClientListByVMMServerResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "InventoryItemsClient.NewListByVMMServerPager") + Fetcher: func(ctx context.Context, page *InventoryItemsClientListByVmmServerResponse) (InventoryItemsClientListByVmmServerResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "InventoryItemsClient.NewListByVmmServerPager") nextLink := "" if page != nil { nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByVMMServerCreateRequest(ctx, resourceGroupName, vmmServerName, options) + return client.listByVmmServerCreateRequest(ctx, resourceGroupName, vmmServerName, options) }, nil) if err != nil { - return InventoryItemsClientListByVMMServerResponse{}, err + return InventoryItemsClientListByVmmServerResponse{}, err } - return client.listByVMMServerHandleResponse(resp) + return client.listByVmmServerHandleResponse(resp) }, Tracer: client.internal.Tracer(), }) } -// listByVMMServerCreateRequest creates the ListByVMMServer request. -func (client *InventoryItemsClient) listByVMMServerCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, options *InventoryItemsClientListByVMMServerOptions) (*policy.Request, error) { +// listByVmmServerCreateRequest creates the ListByVmmServer request. +func (client *InventoryItemsClient) listByVmmServerCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, options *InventoryItemsClientListByVmmServerOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}/inventoryItems" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -296,17 +294,17 @@ func (client *InventoryItemsClient) listByVMMServerCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// listByVMMServerHandleResponse handles the ListByVMMServer response. -func (client *InventoryItemsClient) listByVMMServerHandleResponse(resp *http.Response) (InventoryItemsClientListByVMMServerResponse, error) { - result := InventoryItemsClientListByVMMServerResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.InventoryItemsList); err != nil { - return InventoryItemsClientListByVMMServerResponse{}, err +// listByVmmServerHandleResponse handles the ListByVmmServer response. +func (client *InventoryItemsClient) listByVmmServerHandleResponse(resp *http.Response) (InventoryItemsClientListByVmmServerResponse, error) { + result := InventoryItemsClientListByVmmServerResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.InventoryItemListResult); err != nil { + return InventoryItemsClientListByVmmServerResponse{}, err } return result, nil } diff --git a/sdk/resourcemanager/scvmm/armscvmm/inventoryitems_client_example_test.go b/sdk/resourcemanager/scvmm/armscvmm/inventoryitems_client_example_test.go deleted file mode 100644 index 4975f277b280..000000000000 --- a/sdk/resourcemanager/scvmm/armscvmm/inventoryitems_client_example_test.go +++ /dev/null @@ -1,145 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// 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 armscvmm_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/scvmm/armscvmm" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-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 := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewInventoryItemsClient().Create(ctx, "testrg", "ContosoVMMServer", "12345678-1234-1234-1234-123456789abc", &armscvmm.InventoryItemsClientCreateOptions{Body: &armscvmm.InventoryItem{ - Properties: &armscvmm.CloudInventoryItem{ - InventoryType: to.Ptr(armscvmm.InventoryTypeCloud), - }, - }, - }) - 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 = armscvmm.InventoryItem{ - // Name: to.Ptr("12345678-1234-1234-1234-123456789abc"), - // Type: to.Ptr("Microsoft.SCVMM/VMMServers/InventoryItems"), - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer/InventoryItems/12345678-1234-1234-1234-123456789abc"), - // Properties: &armscvmm.CloudInventoryItem{ - // InventoryItemName: to.Ptr("contoso-cloud"), - // InventoryType: to.Ptr(armscvmm.InventoryTypeCloud), - // ManagedResourceID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/Clouds/contoso-cloud"), - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("12345678-1234-1234-1234-123456789abc"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-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 := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewInventoryItemsClient().Get(ctx, "testrg", "ContosoVMMServer", "12345678-1234-1234-1234-123456789abc", 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 = armscvmm.InventoryItem{ - // Name: to.Ptr("12345678-1234-1234-1234-123456789abc"), - // Type: to.Ptr("Microsoft.SCVMM/VMMServers/InventoryItems"), - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer/InventoryItems/12345678-1234-1234-1234-123456789abc"), - // Properties: &armscvmm.CloudInventoryItem{ - // InventoryItemName: to.Ptr("contoso-cloud"), - // InventoryType: to.Ptr(armscvmm.InventoryTypeCloud), - // ManagedResourceID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/Clouds/contoso-cloud"), - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("12345678-1234-1234-1234-123456789abc"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-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 := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewInventoryItemsClient().Delete(ctx, "testrg", "ContosoVMMServer", "12345678-1234-1234-1234-123456789abc", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListInventoryItemsByVMMServer.json -func ExampleInventoryItemsClient_NewListByVMMServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewInventoryItemsClient().NewListByVMMServerPager("testrg", "ContosoVMMServer", 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 = armscvmm.InventoryItemsList{ - // Value: []*armscvmm.InventoryItem{ - // { - // Name: to.Ptr("12345678-1234-1234-1234-123456789abc"), - // Type: to.Ptr("Microsoft.SCVMM/VMMServers/InventoryItems"), - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer/InventoryItems/12345678-1234-1234-1234-123456789abc"), - // Properties: &armscvmm.CloudInventoryItem{ - // InventoryItemName: to.Ptr("contoso-cloud"), - // InventoryType: to.Ptr(armscvmm.InventoryTypeCloud), - // ManagedResourceID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/Clouds/contoso-cloud"), - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("12345678-1234-1234-1234-123456789abc"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/scvmm/armscvmm/models.go b/sdk/resourcemanager/scvmm/armscvmm/models.go index 72a34a353358..aa6de2fe305e 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/models.go +++ b/sdk/resourcemanager/scvmm/armscvmm/models.go @@ -12,28 +12,28 @@ import "time" // AvailabilitySet - The AvailabilitySets resource definition. type AvailabilitySet struct { - // The extended location. + // REQUIRED; The extended location. ExtendedLocation *ExtendedLocation - // Gets or sets the location. + // REQUIRED; The geo-location where the resource lives Location *string - // Resource properties. + // The resource-specific properties for this resource. Properties *AvailabilitySetProperties - // Resource tags + // Resource tags. Tags map[string]*string - // READ-ONLY; Resource Id + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Resource Name + // 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; Resource Type + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -46,13 +46,13 @@ type AvailabilitySetListItem struct { Name *string } -// AvailabilitySetListResult - List of AvailabilitySets. +// AvailabilitySetListResult - The response of a AvailabilitySet list operation. type AvailabilitySetListResult struct { - // Url to follow for getting next page of resources. - NextLink *string - - // List of AvailabilitySets. + // REQUIRED; The AvailabilitySet items on this page Value []*AvailabilitySet + + // READ-ONLY; The link to the next page of items + NextLink *string } // AvailabilitySetProperties - Defines the resource properties. @@ -63,8 +63,14 @@ type AvailabilitySetProperties struct { // ARM Id of the vmmServer resource in which this resource resides. VmmServerID *string - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState +} + +// AvailabilitySetTagsUpdate - The type used for updating tags in AvailabilitySet resources. +type AvailabilitySetTagsUpdate struct { + // Resource tags. + Tags map[string]*string } // Checkpoint - Defines the resource properties. @@ -87,37 +93,37 @@ type Cloud struct { // REQUIRED; The extended location. ExtendedLocation *ExtendedLocation - // REQUIRED; Gets or sets the location. + // REQUIRED; The geo-location where the resource lives Location *string - // REQUIRED; Resource properties. + // The resource-specific properties for this resource. Properties *CloudProperties - // Resource tags + // Resource tags. Tags map[string]*string - // READ-ONLY; Resource Id + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Resource Name + // 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; Resource Type + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } // CloudCapacity - Cloud Capacity model type CloudCapacity struct { - // CPUCount specifies the maximum number of CPUs that can be allocated in the cloud. + // READ-ONLY; CPUCount specifies the maximum number of CPUs that can be allocated in the cloud. CPUCount *int64 - // MemoryMB specifies a memory usage limit in megabytes. + // READ-ONLY; MemoryMB specifies a memory usage limit in megabytes. MemoryMB *int64 - // VMCount gives the max number of VMs that can be deployed in the cloud. + // READ-ONLY; VMCount gives the max number of VMs that can be deployed in the cloud. VMCount *int64 } @@ -126,16 +132,16 @@ type CloudInventoryItem struct { // REQUIRED; They inventory type. InventoryType *InventoryType - // READ-ONLY; Gets the Managed Object name in VMM for the inventory item. + // READ-ONLY; Gets the Managed Object name in Vmm for the inventory item. InventoryItemName *string // READ-ONLY; Gets the tracked resource id corresponding to the inventory resource. ManagedResourceID *string - // READ-ONLY; Gets the provisioning state. - ProvisioningState *string + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState - // READ-ONLY; Gets the UUID (which is assigned by VMM) for the inventory item. + // READ-ONLY; Gets the UUID (which is assigned by Vmm) for the inventory item. UUID *string } @@ -150,13 +156,13 @@ func (c *CloudInventoryItem) GetInventoryItemProperties() *InventoryItemProperti } } -// CloudListResult - List of Clouds. +// CloudListResult - The response of a Cloud list operation. type CloudListResult struct { - // Url to follow for getting next page of resources. - NextLink *string - - // List of Clouds. + // REQUIRED; The Cloud items on this page Value []*Cloud + + // READ-ONLY; The link to the next page of items + NextLink *string } // CloudProperties - Defines the resource properties. @@ -173,32 +179,54 @@ type CloudProperties struct { // READ-ONLY; Capacity of the cloud. CloudCapacity *CloudCapacity - // READ-ONLY; Name of the cloud in VMMServer. + // READ-ONLY; Name of the cloud in VmmServer. CloudName *string - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState // READ-ONLY; List of QoS policies available for the cloud. - StorageQoSPolicies []*StorageQoSPolicy + StorageQosPolicies []*StorageQosPolicy +} + +// CloudTagsUpdate - The type used for updating tags in Cloud resources. +type CloudTagsUpdate struct { + // Resource tags. + Tags map[string]*string +} + +// 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 } -// ErrorDefinition - Error definition. -type ErrorDefinition struct { - // READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error code. Code *string - // READ-ONLY; Internal error details. - Details []*ErrorDefinition + // READ-ONLY; The error details. + Details []*ErrorDetail - // READ-ONLY; Description of the error. + // READ-ONLY; The error message. Message *string + + // READ-ONLY; The error target. + Target *string } -// ErrorResponse - Error response. +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. +// (This also follows the OData error response format.). type ErrorResponse struct { - // The error details. - Error *ErrorDefinition + // The error object. + Error *ErrorDetail } // ExtendedLocation - The extended location. @@ -210,6 +238,75 @@ type ExtendedLocation struct { Type *string } +// GuestAgent - Defines the GuestAgent. +type GuestAgent struct { + // The resource-specific properties for this resource. + Properties *GuestAgentProperties + + // 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 +} + +// GuestAgentListResult - The response of a GuestAgent list operation. +type GuestAgentListResult struct { + // REQUIRED; The GuestAgent items on this page + Value []*GuestAgent + + // READ-ONLY; The link to the next page of items + NextLink *string +} + +// GuestAgentProperties - Defines the resource properties. +type GuestAgentProperties struct { + // Username / Password Credentials to provision guest agent. + Credentials *GuestCredential + + // 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; Provisioning state of the resource. + ProvisioningState *ProvisioningState + + // READ-ONLY; Gets the guest agent status. + Status *string + + // READ-ONLY; Gets a unique identifier for this resource. + UUID *string +} + +// GuestCredential - Username / Password Credentials to connect to guest. +type GuestCredential struct { + // REQUIRED; Gets or sets the password to connect with the guest. + Password *string + + // REQUIRED; Gets or sets username to connect with the guest. + Username *string +} + +// HTTPProxyConfiguration - HTTP Proxy configuration for the VM. +type HTTPProxyConfiguration struct { + // Gets or sets httpsProxy url. + HTTPSProxy *string +} + // HardwareProfile - Defines the resource properties. type HardwareProfile struct { // Gets or sets the number of vCPUs for the vm. @@ -224,17 +321,17 @@ type HardwareProfile struct { // Gets or sets the min dynamic memory for the vm. DynamicMemoryMinMB *int32 - // Gets highly available property. - IsHighlyAvailable *string - // Gets or sets a value indicating whether to enable processor compatibility mode for live migration of VMs. LimitCPUForMigration *LimitCPUForMigration // MemoryMB is the size of a virtual machine's memory, in MB. MemoryMB *int32 + + // READ-ONLY; Gets highly available property. + IsHighlyAvailable *IsHighlyAvailable } -// HardwareProfileUpdate - Defines the resource properties. +// HardwareProfileUpdate - Defines the resource update properties. type HardwareProfileUpdate struct { // Gets or sets the number of vCPUs for the vm. CPUCount *int32 @@ -255,23 +352,65 @@ type HardwareProfileUpdate struct { MemoryMB *int32 } +// InfrastructureProfile - Specifies the vmmServer infrastructure specific settings for the virtual machine instance. +type InfrastructureProfile struct { + // Gets or sets the bios guid for the vm. + BiosGUID *string + + // Type of checkpoint supported for the vm. + CheckpointType *string + + // ARM Id of the cloud resource to use for deploying the vm. + CloudID *string + + // Gets or sets the generation for the vm. + Generation *int32 + + // Gets or sets the inventory Item ID for the resource. + InventoryItemID *string + + // ARM Id of the template resource to use for deploying the vm. + TemplateID *string + + // Unique ID of the virtual machine. + UUID *string + + // VMName is the name of VM on the SCVmm server. + VMName *string + + // ARM Id of the vmmServer resource in which this resource resides. + VmmServerID *string + + // READ-ONLY; Checkpoints in the vm. + Checkpoints []*Checkpoint + + // READ-ONLY; Last restored checkpoint in the vm. + LastRestoredVMCheckpoint *Checkpoint +} + +// InfrastructureProfileUpdate - Specifies the vmmServer infrastructure specific update settings for the virtual machine instance. +type InfrastructureProfileUpdate struct { + // Type of checkpoint supported for the vm. + CheckpointType *string +} + // InventoryItem - Defines the inventory item. type InventoryItem struct { - // REQUIRED; Resource properties. - Properties InventoryItemPropertiesClassification - // Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are // a kind of Microsoft.Web/sites type. If supported, the resource provider must // validate and persist this value. Kind *string - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // The resource-specific properties for this resource. + Properties InventoryItemPropertiesClassification + + // 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" @@ -283,42 +422,42 @@ type InventoryItemDetails struct { // Gets or sets the inventory Item ID for the resource. InventoryItemID *string - // Gets or sets the Managed Object name in VMM for the resource. + // Gets or sets the Managed Object name in Vmm for the resource. InventoryItemName *string } +// InventoryItemListResult - The response of a InventoryItem list operation. +type InventoryItemListResult struct { + // REQUIRED; The InventoryItem items on this page + Value []*InventoryItem + + // READ-ONLY; The link to the next page of items + NextLink *string +} + // InventoryItemProperties - Defines the resource properties. type InventoryItemProperties struct { // REQUIRED; They inventory type. InventoryType *InventoryType - // READ-ONLY; Gets the Managed Object name in VMM for the inventory item. + // READ-ONLY; Gets the Managed Object name in Vmm for the inventory item. InventoryItemName *string // READ-ONLY; Gets the tracked resource id corresponding to the inventory resource. ManagedResourceID *string - // READ-ONLY; Gets the provisioning state. - ProvisioningState *string + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState - // READ-ONLY; Gets the UUID (which is assigned by VMM) for the inventory item. + // READ-ONLY; Gets the UUID (which is assigned by Vmm) for the inventory item. UUID *string } // GetInventoryItemProperties implements the InventoryItemPropertiesClassification interface for type InventoryItemProperties. func (i *InventoryItemProperties) GetInventoryItemProperties() *InventoryItemProperties { return i } -// InventoryItemsList - List of InventoryItems. -type InventoryItemsList struct { - // REQUIRED; Array of InventoryItems - Value []*InventoryItem - - // Url to follow for getting next page of InventoryItems. - NextLink *string -} - -// NetworkInterfaces - Network Interface model -type NetworkInterfaces struct { +// NetworkInterface - Network Interface model +type NetworkInterface struct { // Gets or sets the ipv4 address type. IPv4AddressType *AllocationMethod @@ -344,18 +483,18 @@ type NetworkInterfaces struct { // when the name is not set. DisplayName *string - // READ-ONLY; Gets or sets the nic ipv4 addresses. + // READ-ONLY; Gets the nic ipv4 addresses. IPv4Addresses []*string - // READ-ONLY; Gets or sets the nic ipv6 addresses. + // READ-ONLY; Gets the nic ipv6 addresses. IPv6Addresses []*string - // READ-ONLY; Gets or sets the name of the virtual network in vmmServer that the nic is connected to. + // READ-ONLY; Gets the name of the virtual network in vmmServer that the nic is connected to. NetworkName *string } -// NetworkInterfacesUpdate - Network Interface model -type NetworkInterfacesUpdate struct { +// NetworkInterfaceUpdate - Network Interface Update model +type NetworkInterfaceUpdate struct { // Gets or sets the ipv4 address type. IPv4AddressType *AllocationMethod @@ -381,102 +520,139 @@ type NetworkInterfacesUpdate struct { // NetworkProfile - Defines the resource properties. type NetworkProfile struct { // Gets or sets the list of network interfaces associated with the virtual machine. - NetworkInterfaces []*NetworkInterfaces + NetworkInterfaces []*NetworkInterface } -// NetworkProfileUpdate - Defines the resource properties. +// NetworkProfileUpdate - Defines the resource update properties. type NetworkProfileUpdate struct { // Gets or sets the list of network interfaces associated with the virtual machine. - NetworkInterfaces []*NetworkInterfacesUpdate + NetworkInterfaces []*NetworkInterfaceUpdate +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. + IsDataAction *bool + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string } -// OsProfile - Defines the resource properties. -type OsProfile struct { +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation +} + +// OsProfileForVMInstance - Defines the resource properties. +type OsProfileForVMInstance struct { // Admin password of the virtual machine. AdminPassword *string // Gets or sets computer name. ComputerName *string - // READ-ONLY; Gets or sets os name. - OSName *string + // Gets or sets the domain name. + DomainName *string + + // Password of the domain the VM has to join. + DomainPassword *string + + // Gets or sets the domain username. + DomainUsername *string + + // Gets or sets the product key.Input format xxxxx-xxxxx-xxxxx-xxxxx-xxxxx + ProductKey *string + + // Get or sets the commands to be run once at the time of creation separated by semicolons. + RunOnceCommands *string + + // Gets or sets the index value of the timezone. + Timezone *int32 + + // Gets or sets the workgroup. + Workgroup *string - // READ-ONLY; Gets or sets the type of the os. + // READ-ONLY; Gets os sku. + OSSKU *string + + // READ-ONLY; Gets the type of the os. OSType *OsType + + // READ-ONLY; Gets os version. + OSVersion *string } // ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a // location type ProxyResource struct { - // 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; 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 } // Resource - Common fields that are returned in the response for all Azure Resource Manager resources type Resource struct { - // 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; 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 } -// ResourcePatch - Object containing tags updates for patch operations. -type ResourcePatch struct { - // Resource tags. - Tags map[string]*string -} - -// ResourceProviderOperation - Results of the request to list operations. -type ResourceProviderOperation struct { - // Display metadata associated with the operation. - Display *ResourceProviderOperationDisplay - - // Indicates whether the operation applies to data-plane. - IsDataAction *string - - // Operation name, in format of {provider}/{resource}/{operation}. - Name *string -} - -// ResourceProviderOperationDisplay - Display metadata associated with the operation. -type ResourceProviderOperationDisplay struct { - // Description of this operation. - Description *string - - // Type of operation: read, write, delete, etc. - Operation *string - - // The resource provider. - Provider *string - - // Resource on which the operation is performed. - Resource *string -} - -// ResourceProviderOperationList - Results of the request to list operations. -type ResourceProviderOperationList struct { - // Url to follow for getting next page of resources. - NextLink *string - - // List of Operations. - Value []*ResourceProviderOperation -} - // StopVirtualMachineOptions - Defines the stop action properties. type StopVirtualMachineOptions struct { // Gets or sets a value indicating whether to request non-graceful VM shutdown. True value for this flag indicates non-graceful // shutdown whereas false indicates otherwise. Defaults to false. - SkipShutdown *bool + SkipShutdown *SkipShutdown } // StorageProfile - Defines the resource properties. @@ -485,14 +661,14 @@ type StorageProfile struct { Disks []*VirtualDisk } -// StorageProfileUpdate - Defines the resource properties. +// StorageProfileUpdate - Defines the resource update properties. type StorageProfileUpdate struct { // Gets or sets the list of virtual disks associated with the virtual machine. Disks []*VirtualDiskUpdate } -// StorageQoSPolicy - The StorageQoSPolicy definition. -type StorageQoSPolicy struct { +// StorageQosPolicy - The StorageQoSPolicy definition. +type StorageQosPolicy struct { // The Bandwidth Limit for internet traffic. BandwidthLimit *int64 @@ -512,8 +688,8 @@ type StorageQoSPolicy struct { PolicyID *string } -// StorageQoSPolicyDetails - The StorageQoSPolicyDetails definition. -type StorageQoSPolicyDetails struct { +// StorageQosPolicyDetails - The StorageQoSPolicyDetails definition. +type StorageQosPolicyDetails struct { // The ID of the QoS policy. ID *string @@ -542,76 +718,65 @@ type SystemData struct { LastModifiedByType *CreatedByType } -// VMMServer - The VmmServers resource definition. -type VMMServer struct { - // REQUIRED; The extended location. - ExtendedLocation *ExtendedLocation - - // REQUIRED; Gets or sets the location. +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' +// and a 'location' +type TrackedResource struct { + // REQUIRED; The geo-location where the resource lives Location *string - // REQUIRED; Resource properties. - Properties *VMMServerProperties - - // Resource tags + // Resource tags. Tags map[string]*string - // READ-ONLY; Resource Id + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Resource Name + // 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; Resource Type + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// VMMServerListResult - List of VmmServers. -type VMMServerListResult struct { - // Url to follow for getting next page of resources. - NextLink *string +// VMInstanceHybridIdentityMetadata - Defines the HybridIdentityMetadata. +type VMInstanceHybridIdentityMetadata struct { + // The resource-specific properties for this resource. + Properties *VMInstanceHybridIdentityMetadataProperties - // List of VmmServers. - Value []*VMMServer -} - -// VMMServerProperties - Defines the resource properties. -type VMMServerProperties struct { - // REQUIRED; Fqdn is the hostname/ip of the vmmServer. - Fqdn *string - - // Credentials to connect to VMMServer. - Credentials *VMMServerPropertiesCredentials - - // Port is the port on which the vmmServer is listening. - Port *int32 + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string - // READ-ONLY; Gets or sets the connection status to the vmmServer. - ConnectionStatus *string + // READ-ONLY; The name of the resource + Name *string - // READ-ONLY; Gets or sets any error message if connection to vmmServer is having any issue. - ErrorMessage *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} - // READ-ONLY; Unique ID of vmmServer. - UUID *string +// VMInstanceHybridIdentityMetadataListResult - The response of a VmInstanceHybridIdentityMetadata list operation. +type VMInstanceHybridIdentityMetadataListResult struct { + // REQUIRED; The VmInstanceHybridIdentityMetadata items on this page + Value []*VMInstanceHybridIdentityMetadata - // READ-ONLY; Version is the version of the vmmSever. - Version *string + // READ-ONLY; The link to the next page of items + NextLink *string } -// VMMServerPropertiesCredentials - Credentials to connect to VMMServer. -type VMMServerPropertiesCredentials struct { - // Credentials to use to connect to VMMServer. - Password *string +// VMInstanceHybridIdentityMetadataProperties - Describes the properties of Hybrid Identity Metadata for a Virtual Machine. +type VMInstanceHybridIdentityMetadataProperties struct { + // Gets or sets the Public Key. + PublicKey *string - // Username to use to connect to VMMServer. - Username *string + // The unique identifier for the resource. + ResourceUID *string + + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState } // VirtualDisk - Virtual disk model @@ -638,7 +803,7 @@ type VirtualDisk struct { Name *string // The QoS policy for the disk. - StorageQoSPolicy *StorageQoSPolicyDetails + StorageQosPolicy *StorageQosPolicyDetails // Gets or sets the disk id in the template. TemplateDiskID *string @@ -650,17 +815,17 @@ type VirtualDisk struct { // the name is not set. DisplayName *string - // READ-ONLY; Gets or sets the max disk size. + // READ-ONLY; Gets the max disk size. MaxDiskSizeGB *int32 // READ-ONLY; Gets the disk vhd format type. VhdFormatType *string - // READ-ONLY; Gets or sets the disk volume type. + // READ-ONLY; Gets the disk volume type. VolumeType *string } -// VirtualDiskUpdate - Virtual disk model +// VirtualDiskUpdate - Virtual Disk Update model type VirtualDiskUpdate struct { // Gets or sets the disk bus. Bus *int32 @@ -681,52 +846,106 @@ type VirtualDiskUpdate struct { Name *string // The QoS policy for the disk. - StorageQoSPolicy *StorageQoSPolicyDetails + StorageQosPolicy *StorageQosPolicyDetails // Gets or sets the disk vhd type. VhdType *string } -// VirtualMachine - The VirtualMachines resource definition. -type VirtualMachine struct { - // REQUIRED; The extended location. - ExtendedLocation *ExtendedLocation +// VirtualMachineCreateCheckpoint - Defines the create checkpoint action properties. +type VirtualMachineCreateCheckpoint struct { + // Description of the checkpoint. + Description *string - // REQUIRED; Gets or sets the location. - Location *string + // Name of the checkpoint. + Name *string +} - // REQUIRED; Resource properties. - Properties *VirtualMachineProperties +// VirtualMachineDeleteCheckpoint - Defines the delete checkpoint action properties. +type VirtualMachineDeleteCheckpoint struct { + // ID of the checkpoint to be deleted. + ID *string +} - // Resource tags - Tags map[string]*string +// VirtualMachineInstance - Define the virtualMachineInstance. +type VirtualMachineInstance struct { + // REQUIRED; Gets or sets the extended location. + ExtendedLocation *ExtendedLocation + + // The resource-specific properties for this resource. + Properties *VirtualMachineInstanceProperties - // READ-ONLY; Resource Id + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Resource Name + // 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; Resource Type + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// VirtualMachineCreateCheckpoint - Defines the create checkpoint action properties. -type VirtualMachineCreateCheckpoint struct { - // Description of the checkpoint. - Description *string +// VirtualMachineInstanceListResult - The response of a VirtualMachineInstance list operation. +type VirtualMachineInstanceListResult struct { + // REQUIRED; The VirtualMachineInstance items on this page + Value []*VirtualMachineInstance - // Name of the checkpoint. - Name *string + // READ-ONLY; The link to the next page of items + NextLink *string } -// VirtualMachineDeleteCheckpoint - Defines the delete checkpoint action properties. -type VirtualMachineDeleteCheckpoint struct { - // ID of the checkpoint to be deleted. - ID *string +// VirtualMachineInstanceProperties - Defines the resource properties. +type VirtualMachineInstanceProperties struct { + // Availability Sets in vm. + AvailabilitySets []*AvailabilitySetListItem + + // Hardware properties. + HardwareProfile *HardwareProfile + + // Gets the infrastructure profile. + InfrastructureProfile *InfrastructureProfile + + // Network properties. + NetworkProfile *NetworkProfile + + // OS properties. + OSProfile *OsProfileForVMInstance + + // Storage properties. + StorageProfile *StorageProfile + + // READ-ONLY; Gets the power state of the virtual machine. + PowerState *string + + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState +} + +// VirtualMachineInstanceUpdate - The type used for update operations of the VirtualMachineInstance. +type VirtualMachineInstanceUpdate struct { + // The update properties of the VirtualMachineInstance. + Properties *VirtualMachineInstanceUpdateProperties +} + +// VirtualMachineInstanceUpdateProperties - Virtual Machine Instance Properties Update model +type VirtualMachineInstanceUpdateProperties struct { + // Availability Sets in vm. + AvailabilitySets []*AvailabilitySetListItem + + // Hardware properties. + HardwareProfile *HardwareProfileUpdate + + // Gets the infrastructure profile. + InfrastructureProfile *InfrastructureProfileUpdate + + // Network properties. + NetworkProfile *NetworkProfileUpdate + + // Storage properties. + StorageProfile *StorageProfileUpdate } // VirtualMachineInventoryItem - The Virtual machine inventory item. @@ -740,25 +959,34 @@ type VirtualMachineInventoryItem struct { // Gets or sets the nic ip addresses. IPAddresses []*string - // READ-ONLY; Gets the Managed Object name in VMM for the inventory item. + // READ-ONLY; Gets the bios guid. + BiosGUID *string + + // READ-ONLY; Gets the Managed Object name in Vmm for the inventory item. InventoryItemName *string + // READ-ONLY; Gets the tracked resource id corresponding to the inventory resource. + ManagedMachineResourceID *string + // READ-ONLY; Gets the tracked resource id corresponding to the inventory resource. ManagedResourceID *string - // READ-ONLY; Gets or sets os name. + // READ-ONLY; Gets os name. OSName *string - // READ-ONLY; Gets or sets the type of the os. + // READ-ONLY; Gets the type of the os. OSType *OsType + // READ-ONLY; Gets os version. + OSVersion *string + // READ-ONLY; Gets the power state of the virtual machine. PowerState *string - // READ-ONLY; Gets the provisioning state. - ProvisioningState *string + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState - // READ-ONLY; Gets the UUID (which is assigned by VMM) for the inventory item. + // READ-ONLY; Gets the UUID (which is assigned by Vmm) for the inventory item. UUID *string } @@ -773,66 +1001,6 @@ func (v *VirtualMachineInventoryItem) GetInventoryItemProperties() *InventoryIte } } -// VirtualMachineListResult - List of VirtualMachines. -type VirtualMachineListResult struct { - // Url to follow for getting next page of resources. - NextLink *string - - // List of VirtualMachines. - Value []*VirtualMachine -} - -// VirtualMachineProperties - Defines the resource properties. -type VirtualMachineProperties struct { - // Availability Sets in vm. - AvailabilitySets []*AvailabilitySetListItem - - // Type of checkpoint supported for the vm. - CheckpointType *string - - // Checkpoints in the vm. - Checkpoints []*Checkpoint - - // ARM Id of the cloud resource to use for deploying the vm. - CloudID *string - - // Gets or sets the generation for the vm. - Generation *int32 - - // Hardware properties. - HardwareProfile *HardwareProfile - - // Gets or sets the inventory Item ID for the resource. - InventoryItemID *string - - // Network properties. - NetworkProfile *NetworkProfile - - // OS properties. - OSProfile *OsProfile - - // Storage properties. - StorageProfile *StorageProfile - - // ARM Id of the template resource to use for deploying the vm. - TemplateID *string - - // Unique ID of the virtual machine. - UUID *string - - // VMName is the name of VM on the SCVMM server. - VMName *string - - // ARM Id of the vmmServer resource in which this resource resides. - VmmServerID *string - - // READ-ONLY; Gets the power state of the virtual machine. - PowerState *string - - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string -} - // VirtualMachineRestoreCheckpoint - Defines the restore checkpoint action properties. type VirtualMachineRestoreCheckpoint struct { // ID of the checkpoint to be restored to. @@ -844,25 +1012,25 @@ type VirtualMachineTemplate struct { // REQUIRED; The extended location. ExtendedLocation *ExtendedLocation - // REQUIRED; Gets or sets the location. + // REQUIRED; The geo-location where the resource lives Location *string - // REQUIRED; Resource properties. + // The resource-specific properties for this resource. Properties *VirtualMachineTemplateProperties - // Resource tags + // Resource tags. Tags map[string]*string - // READ-ONLY; Resource Id + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Resource Name + // 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; Resource Type + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -871,10 +1039,10 @@ type VirtualMachineTemplateInventoryItem struct { // REQUIRED; They inventory type. InventoryType *InventoryType - // READ-ONLY; Gets or sets the desired number of vCPUs for the vm. + // READ-ONLY; Gets the desired number of vCPUs for the vm. CPUCount *int32 - // READ-ONLY; Gets the Managed Object name in VMM for the inventory item. + // READ-ONLY; Gets the Managed Object name in Vmm for the inventory item. InventoryItemName *string // READ-ONLY; Gets the tracked resource id corresponding to the inventory resource. @@ -883,16 +1051,16 @@ type VirtualMachineTemplateInventoryItem struct { // READ-ONLY; MemoryMB is the desired size of a virtual machine's memory, in MB. MemoryMB *int32 - // READ-ONLY; Gets or sets os name. + // READ-ONLY; Gets os name. OSName *string - // READ-ONLY; Gets or sets the type of the os. + // READ-ONLY; Gets the type of the os. OSType *OsType - // READ-ONLY; Gets the provisioning state. - ProvisioningState *string + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState - // READ-ONLY; Gets the UUID (which is assigned by VMM) for the inventory item. + // READ-ONLY; Gets the UUID (which is assigned by Vmm) for the inventory item. UUID *string } @@ -907,13 +1075,13 @@ func (v *VirtualMachineTemplateInventoryItem) GetInventoryItemProperties() *Inve } } -// VirtualMachineTemplateListResult - List of VirtualMachineTemplates. +// VirtualMachineTemplateListResult - The response of a VirtualMachineTemplate list operation. type VirtualMachineTemplateListResult struct { - // Url to follow for getting next page of resources. - NextLink *string - - // List of VirtualMachineTemplates. + // REQUIRED; The VirtualMachineTemplate items on this page Value []*VirtualMachineTemplate + + // READ-ONLY; The link to the next page of items + NextLink *string } // VirtualMachineTemplateProperties - Defines the resource properties. @@ -927,100 +1095,82 @@ type VirtualMachineTemplateProperties struct { // ARM Id of the vmmServer resource in which this resource resides. VmmServerID *string - // READ-ONLY; Gets or sets the desired number of vCPUs for the vm. + // READ-ONLY; Gets the desired number of vCPUs for the vm. CPUCount *int32 - // READ-ONLY; Gets or sets computer name. + // READ-ONLY; Gets computer name. ComputerName *string - // READ-ONLY; Gets or sets the disks of the template. + // READ-ONLY; Gets the disks of the template. Disks []*VirtualDisk - // READ-ONLY; Gets or sets a value indicating whether to enable dynamic memory or not. + // READ-ONLY; Gets a value indicating whether to enable dynamic memory or not. DynamicMemoryEnabled *DynamicMemoryEnabled - // READ-ONLY; Gets or sets the max dynamic memory for the vm. + // READ-ONLY; Gets the max dynamic memory for the vm. DynamicMemoryMaxMB *int32 - // READ-ONLY; Gets or sets the min dynamic memory for the vm. + // READ-ONLY; Gets the min dynamic memory for the vm. DynamicMemoryMinMB *int32 - // READ-ONLY; Gets or sets the generation for the vm. + // READ-ONLY; Gets the generation for the vm. Generation *int32 - // READ-ONLY; Gets or sets a value indicating whether the vm template is customizable or not. + // READ-ONLY; Gets a value indicating whether the vm template is customizable or not. IsCustomizable *IsCustomizable // READ-ONLY; Gets highly available property. - IsHighlyAvailable *string + IsHighlyAvailable *IsHighlyAvailable - // READ-ONLY; Gets or sets a value indicating whether to enable processor compatibility mode for live migration of VMs. + // READ-ONLY; Gets a value indicating whether to enable processor compatibility mode for live migration of VMs. LimitCPUForMigration *LimitCPUForMigration // READ-ONLY; MemoryMB is the desired size of a virtual machine's memory, in MB. MemoryMB *int32 - // READ-ONLY; Gets or sets the network interfaces of the template. - NetworkInterfaces []*NetworkInterfaces + // READ-ONLY; Gets the network interfaces of the template. + NetworkInterfaces []*NetworkInterface - // READ-ONLY; Gets or sets os name. + // READ-ONLY; Gets os name. OSName *string - // READ-ONLY; Gets or sets the type of the os. + // READ-ONLY; Gets the type of the os. OSType *OsType - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState } -// VirtualMachineUpdate - Defines the virtualMachineUpdate. -type VirtualMachineUpdate struct { - // Defines the resource properties. - Properties *VirtualMachineUpdateProperties - - // Gets or sets the Resource tags. +// VirtualMachineTemplateTagsUpdate - The type used for updating tags in VirtualMachineTemplate resources. +type VirtualMachineTemplateTagsUpdate struct { + // Resource tags. Tags map[string]*string } -// VirtualMachineUpdateProperties - Defines the resource properties. -type VirtualMachineUpdateProperties struct { - // Availability Sets in vm. - AvailabilitySets []*AvailabilitySetListItem - - // Defines the resource properties. - HardwareProfile *HardwareProfileUpdate - - // Defines the resource properties. - NetworkProfile *NetworkProfileUpdate - - // Defines the resource properties. - StorageProfile *StorageProfileUpdate -} - // VirtualNetwork - The VirtualNetworks resource definition. type VirtualNetwork struct { // REQUIRED; The extended location. ExtendedLocation *ExtendedLocation - // REQUIRED; Gets or sets the location. + // REQUIRED; The geo-location where the resource lives Location *string - // REQUIRED; Resource properties. + // The resource-specific properties for this resource. Properties *VirtualNetworkProperties - // Resource tags + // Resource tags. Tags map[string]*string - // READ-ONLY; Resource Id + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Resource Name + // 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; Resource Type + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -1029,16 +1179,16 @@ type VirtualNetworkInventoryItem struct { // REQUIRED; They inventory type. InventoryType *InventoryType - // READ-ONLY; Gets the Managed Object name in VMM for the inventory item. + // READ-ONLY; Gets the Managed Object name in Vmm for the inventory item. InventoryItemName *string // READ-ONLY; Gets the tracked resource id corresponding to the inventory resource. ManagedResourceID *string - // READ-ONLY; Gets the provisioning state. - ProvisioningState *string + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState - // READ-ONLY; Gets the UUID (which is assigned by VMM) for the inventory item. + // READ-ONLY; Gets the UUID (which is assigned by Vmm) for the inventory item. UUID *string } @@ -1053,13 +1203,13 @@ func (v *VirtualNetworkInventoryItem) GetInventoryItemProperties() *InventoryIte } } -// VirtualNetworkListResult - List of VirtualNetworks. +// VirtualNetworkListResult - The response of a VirtualNetwork list operation. type VirtualNetworkListResult struct { - // Url to follow for getting next page of resources. - NextLink *string - - // List of VirtualNetworks. + // REQUIRED; The VirtualNetwork items on this page Value []*VirtualNetwork + + // READ-ONLY; The link to the next page of items + NextLink *string } // VirtualNetworkProperties - Defines the resource properties. @@ -1076,6 +1226,90 @@ type VirtualNetworkProperties struct { // READ-ONLY; Name of the virtual network in vmmServer. NetworkName *string - // READ-ONLY; Gets or sets the provisioning state. - ProvisioningState *string + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState +} + +// VirtualNetworkTagsUpdate - The type used for updating tags in VirtualNetwork resources. +type VirtualNetworkTagsUpdate struct { + // Resource tags. + Tags map[string]*string +} + +// VmmCredential - Credentials to connect to VmmServer. +type VmmCredential struct { + // Password to use to connect to VmmServer. + Password *string + + // Username to use to connect to VmmServer. + Username *string +} + +// VmmServer - The VmmServers resource definition. +type VmmServer struct { + // REQUIRED; The extended location. + ExtendedLocation *ExtendedLocation + + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *VmmServerProperties + + // Resource tags. + Tags map[string]*string + + // 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 +} + +// VmmServerListResult - The response of a VmmServer list operation. +type VmmServerListResult struct { + // REQUIRED; The VmmServer items on this page + Value []*VmmServer + + // READ-ONLY; The link to the next page of items + NextLink *string +} + +// VmmServerProperties - Defines the resource properties. +type VmmServerProperties struct { + // REQUIRED; Fqdn is the hostname/ip of the vmmServer. + Fqdn *string + + // Credentials to connect to VmmServer. + Credentials *VmmCredential + + // Port is the port on which the vmmServer is listening. + Port *int32 + + // READ-ONLY; Gets the connection status to the vmmServer. + ConnectionStatus *string + + // READ-ONLY; Gets any error message if connection to vmmServer is having any issue. + ErrorMessage *string + + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState + + // READ-ONLY; Unique ID of vmmServer. + UUID *string + + // READ-ONLY; Version is the version of the vmmSever. + Version *string +} + +// VmmServerTagsUpdate - The type used for updating tags in VmmServer resources. +type VmmServerTagsUpdate struct { + // Resource tags. + Tags map[string]*string } diff --git a/sdk/resourcemanager/scvmm/armscvmm/models_serde.go b/sdk/resourcemanager/scvmm/armscvmm/models_serde.go index f754ee5a90fb..55ac9d840185 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/models_serde.go +++ b/sdk/resourcemanager/scvmm/armscvmm/models_serde.go @@ -167,6 +167,33 @@ func (a *AvailabilitySetProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type AvailabilitySetTagsUpdate. +func (a AvailabilitySetTagsUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailabilitySetTagsUpdate. +func (a *AvailabilitySetTagsUpdate) 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", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Checkpoint. func (c Checkpoint) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -377,7 +404,7 @@ func (c CloudProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "cloudName", c.CloudName) populate(objectMap, "inventoryItemId", c.InventoryItemID) populate(objectMap, "provisioningState", c.ProvisioningState) - populate(objectMap, "storageQoSPolicies", c.StorageQoSPolicies) + populate(objectMap, "storageQoSPolicies", c.StorageQosPolicies) populate(objectMap, "uuid", c.UUID) populate(objectMap, "vmmServerId", c.VmmServerID) return json.Marshal(objectMap) @@ -405,7 +432,7 @@ func (c *CloudProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "ProvisioningState", &c.ProvisioningState) delete(rawMsg, key) case "storageQoSPolicies": - err = unpopulate(val, "StorageQoSPolicies", &c.StorageQoSPolicies) + err = unpopulate(val, "StorageQosPolicies", &c.StorageQosPolicies) delete(rawMsg, key) case "uuid": err = unpopulate(val, "UUID", &c.UUID) @@ -421,17 +448,77 @@ func (c *CloudProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorDefinition. -func (e ErrorDefinition) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CloudTagsUpdate. +func (c CloudTagsUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CloudTagsUpdate. +func (c *CloudTagsUpdate) 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", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + 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) + populate(objectMap, "target", e.Target) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDefinition. -func (e *ErrorDefinition) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) 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) @@ -439,6 +526,9 @@ func (e *ErrorDefinition) 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) @@ -448,6 +538,9 @@ func (e *ErrorDefinition) UnmarshalJSON(data []byte) error { case "message": err = unpopulate(val, "Message", &e.Message) delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -514,6 +607,193 @@ func (e *ExtendedLocation) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type GuestAgent. +func (g GuestAgent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", g.ID) + populate(objectMap, "name", g.Name) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "systemData", g.SystemData) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GuestAgent. +func (g *GuestAgent) 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 "id": + err = unpopulate(val, "ID", &g.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &g.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &g.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &g.Type) + 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 GuestAgentListResult. +func (g GuestAgentListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", g.NextLink) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GuestAgentListResult. +func (g *GuestAgentListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &g.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &g.Value) + 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) + populate(objectMap, "uuid", g.UUID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GuestAgentProperties. +func (g *GuestAgentProperties) 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 "credentials": + err = unpopulate(val, "Credentials", &g.Credentials) + delete(rawMsg, key) + case "customResourceName": + err = unpopulate(val, "CustomResourceName", &g.CustomResourceName) + delete(rawMsg, key) + 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) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &g.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &g.Status) + delete(rawMsg, key) + case "uuid": + err = unpopulate(val, "UUID", &g.UUID) + 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 GuestCredential. +func (g GuestCredential) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "password", g.Password) + populate(objectMap, "username", g.Username) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GuestCredential. +func (g *GuestCredential) 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 "password": + err = unpopulate(val, "Password", &g.Password) + delete(rawMsg, key) + case "username": + err = unpopulate(val, "Username", &g.Username) + 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 HTTPProxyConfiguration. +func (h HTTPProxyConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "httpsProxy", h.HTTPSProxy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HTTPProxyConfiguration. +func (h *HTTPProxyConfiguration) 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", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "httpsProxy": + err = unpopulate(val, "HTTPSProxy", &h.HTTPSProxy) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type HardwareProfile. func (h HardwareProfile) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -612,6 +892,100 @@ func (h *HardwareProfileUpdate) 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, "biosGuid", i.BiosGUID) + populate(objectMap, "checkpointType", i.CheckpointType) + populate(objectMap, "checkpoints", i.Checkpoints) + populate(objectMap, "cloudId", i.CloudID) + populate(objectMap, "generation", i.Generation) + populate(objectMap, "inventoryItemId", i.InventoryItemID) + populate(objectMap, "lastRestoredVMCheckpoint", i.LastRestoredVMCheckpoint) + populate(objectMap, "templateId", i.TemplateID) + populate(objectMap, "uuid", i.UUID) + populate(objectMap, "vmName", i.VMName) + populate(objectMap, "vmmServerId", i.VmmServerID) + 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 "biosGuid": + err = unpopulate(val, "BiosGUID", &i.BiosGUID) + delete(rawMsg, key) + case "checkpointType": + err = unpopulate(val, "CheckpointType", &i.CheckpointType) + delete(rawMsg, key) + case "checkpoints": + err = unpopulate(val, "Checkpoints", &i.Checkpoints) + delete(rawMsg, key) + case "cloudId": + err = unpopulate(val, "CloudID", &i.CloudID) + delete(rawMsg, key) + case "generation": + err = unpopulate(val, "Generation", &i.Generation) + delete(rawMsg, key) + case "inventoryItemId": + err = unpopulate(val, "InventoryItemID", &i.InventoryItemID) + delete(rawMsg, key) + case "lastRestoredVMCheckpoint": + err = unpopulate(val, "LastRestoredVMCheckpoint", &i.LastRestoredVMCheckpoint) + delete(rawMsg, key) + case "templateId": + err = unpopulate(val, "TemplateID", &i.TemplateID) + delete(rawMsg, key) + case "uuid": + err = unpopulate(val, "UUID", &i.UUID) + delete(rawMsg, key) + case "vmName": + err = unpopulate(val, "VMName", &i.VMName) + delete(rawMsg, key) + case "vmmServerId": + err = unpopulate(val, "VmmServerID", &i.VmmServerID) + 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 InfrastructureProfileUpdate. +func (i InfrastructureProfileUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "checkpointType", i.CheckpointType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InfrastructureProfileUpdate. +func (i *InfrastructureProfileUpdate) 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 "checkpointType": + err = unpopulate(val, "CheckpointType", &i.CheckpointType) + 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) @@ -690,19 +1064,16 @@ func (i *InventoryItemDetails) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type InventoryItemProperties. -func (i InventoryItemProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InventoryItemListResult. +func (i InventoryItemListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "inventoryItemName", i.InventoryItemName) - objectMap["inventoryType"] = i.InventoryType - populate(objectMap, "managedResourceId", i.ManagedResourceID) - populate(objectMap, "provisioningState", i.ProvisioningState) - populate(objectMap, "uuid", i.UUID) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type InventoryItemProperties. -func (i *InventoryItemProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InventoryItemListResult. +func (i *InventoryItemListResult) 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) @@ -710,20 +1081,11 @@ func (i *InventoryItemProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "inventoryItemName": - err = unpopulate(val, "InventoryItemName", &i.InventoryItemName) - delete(rawMsg, key) - case "inventoryType": - err = unpopulate(val, "InventoryType", &i.InventoryType) - delete(rawMsg, key) - case "managedResourceId": - err = unpopulate(val, "ManagedResourceID", &i.ManagedResourceID) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &i.ProvisioningState) + case "nextLink": + err = unpopulate(val, "NextLink", &i.NextLink) delete(rawMsg, key) - case "uuid": - err = unpopulate(val, "UUID", &i.UUID) + case "value": + err = unpopulate(val, "Value", &i.Value) delete(rawMsg, key) } if err != nil { @@ -733,16 +1095,19 @@ func (i *InventoryItemProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type InventoryItemsList. -func (i InventoryItemsList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type InventoryItemProperties. +func (i InventoryItemProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", i.NextLink) - populate(objectMap, "value", i.Value) + populate(objectMap, "inventoryItemName", i.InventoryItemName) + objectMap["inventoryType"] = i.InventoryType + populate(objectMap, "managedResourceId", i.ManagedResourceID) + populate(objectMap, "provisioningState", i.ProvisioningState) + populate(objectMap, "uuid", i.UUID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type InventoryItemsList. -func (i *InventoryItemsList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type InventoryItemProperties. +func (i *InventoryItemProperties) 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) @@ -750,11 +1115,20 @@ func (i *InventoryItemsList) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &i.NextLink) + case "inventoryItemName": + err = unpopulate(val, "InventoryItemName", &i.InventoryItemName) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &i.Value) + case "inventoryType": + err = unpopulate(val, "InventoryType", &i.InventoryType) + delete(rawMsg, key) + case "managedResourceId": + err = unpopulate(val, "ManagedResourceID", &i.ManagedResourceID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &i.ProvisioningState) + delete(rawMsg, key) + case "uuid": + err = unpopulate(val, "UUID", &i.UUID) delete(rawMsg, key) } if err != nil { @@ -764,8 +1138,8 @@ func (i *InventoryItemsList) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type NetworkInterfaces. -func (n NetworkInterfaces) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type NetworkInterface. +func (n NetworkInterface) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "displayName", n.DisplayName) populate(objectMap, "ipv4AddressType", n.IPv4AddressType) @@ -781,8 +1155,8 @@ func (n NetworkInterfaces) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkInterfaces. -func (n *NetworkInterfaces) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkInterface. +func (n *NetworkInterface) 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", n, err) @@ -831,8 +1205,8 @@ func (n *NetworkInterfaces) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type NetworkInterfacesUpdate. -func (n NetworkInterfacesUpdate) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type NetworkInterfaceUpdate. +func (n NetworkInterfaceUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "ipv4AddressType", n.IPv4AddressType) populate(objectMap, "ipv6AddressType", n.IPv6AddressType) @@ -844,8 +1218,8 @@ func (n NetworkInterfacesUpdate) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkInterfacesUpdate. -func (n *NetworkInterfacesUpdate) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkInterfaceUpdate. +func (n *NetworkInterfaceUpdate) 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", n, err) @@ -936,18 +1310,19 @@ func (n *NetworkProfileUpdate) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type OsProfile. -func (o OsProfile) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "adminPassword", o.AdminPassword) - populate(objectMap, "computerName", o.ComputerName) - populate(objectMap, "osName", o.OSName) - populate(objectMap, "osType", o.OSType) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type OsProfile. -func (o *OsProfile) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) 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) @@ -955,17 +1330,20 @@ func (o *OsProfile) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "adminPassword": - err = unpopulate(val, "AdminPassword", &o.AdminPassword) + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) delete(rawMsg, key) - case "computerName": - err = unpopulate(val, "ComputerName", &o.ComputerName) + case "display": + err = unpopulate(val, "Display", &o.Display) delete(rawMsg, key) - case "osName": - err = unpopulate(val, "OSName", &o.OSName) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) delete(rawMsg, key) - case "osType": - err = unpopulate(val, "OSType", &o.OSType) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) delete(rawMsg, key) } if err != nil { @@ -975,187 +1353,198 @@ func (o *OsProfile) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ProxyResource. -func (p ProxyResource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", p.ID) - populate(objectMap, "name", p.Name) - populate(objectMap, "type", p.Type) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. -func (p *ProxyResource) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) 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", p, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &p.ID) + case "description": + err = unpopulate(val, "Description", &o.Description) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &p.Name) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &p.Type) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Resource. -func (r Resource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", r.ID) - populate(objectMap, "name", r.Name) - populate(objectMap, "type", r.Type) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. -func (r *Resource) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) 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", r, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &r.Name) + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &r.Type) + case "value": + err = unpopulate(val, "Value", &o.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ResourcePatch. -func (r ResourcePatch) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type OsProfileForVMInstance. +func (o OsProfileForVMInstance) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "tags", r.Tags) + populate(objectMap, "adminPassword", o.AdminPassword) + populate(objectMap, "computerName", o.ComputerName) + populate(objectMap, "domainName", o.DomainName) + populate(objectMap, "domainPassword", o.DomainPassword) + populate(objectMap, "domainUsername", o.DomainUsername) + populate(objectMap, "osSku", o.OSSKU) + populate(objectMap, "osType", o.OSType) + populate(objectMap, "osVersion", o.OSVersion) + populate(objectMap, "productKey", o.ProductKey) + populate(objectMap, "runOnceCommands", o.RunOnceCommands) + populate(objectMap, "timezone", o.Timezone) + populate(objectMap, "workgroup", o.Workgroup) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourcePatch. -func (r *ResourcePatch) UnmarshalJSON(data []byte) error { +// 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", r, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } for key, val := range rawMsg { var err error switch key { - case "tags": - err = unpopulate(val, "Tags", &r.Tags) + case "adminPassword": + err = unpopulate(val, "AdminPassword", &o.AdminPassword) delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ResourceProviderOperation. -func (r ResourceProviderOperation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "display", r.Display) - populate(objectMap, "isDataAction", r.IsDataAction) - populate(objectMap, "name", r.Name) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderOperation. -func (r *ResourceProviderOperation) 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", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "display": - err = unpopulate(val, "Display", &r.Display) + case "computerName": + err = unpopulate(val, "ComputerName", &o.ComputerName) delete(rawMsg, key) - case "isDataAction": - err = unpopulate(val, "IsDataAction", &r.IsDataAction) + case "domainName": + err = unpopulate(val, "DomainName", &o.DomainName) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &r.Name) + case "domainPassword": + err = unpopulate(val, "DomainPassword", &o.DomainPassword) + delete(rawMsg, key) + case "domainUsername": + err = unpopulate(val, "DomainUsername", &o.DomainUsername) + 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 "osVersion": + err = unpopulate(val, "OSVersion", &o.OSVersion) + delete(rawMsg, key) + case "productKey": + err = unpopulate(val, "ProductKey", &o.ProductKey) + delete(rawMsg, key) + case "runOnceCommands": + err = unpopulate(val, "RunOnceCommands", &o.RunOnceCommands) + delete(rawMsg, key) + case "timezone": + err = unpopulate(val, "Timezone", &o.Timezone) + delete(rawMsg, key) + case "workgroup": + err = unpopulate(val, "Workgroup", &o.Workgroup) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ResourceProviderOperationDisplay. -func (r ResourceProviderOperationDisplay) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "description", r.Description) - populate(objectMap, "operation", r.Operation) - populate(objectMap, "provider", r.Provider) - populate(objectMap, "resource", r.Resource) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "type", p.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderOperationDisplay. -func (r *ResourceProviderOperationDisplay) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. +func (p *ProxyResource) 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", r, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } for key, val := range rawMsg { var err error switch key { - case "description": - err = unpopulate(val, "Description", &r.Description) + case "id": + err = unpopulate(val, "ID", &p.ID) delete(rawMsg, key) - case "operation": - err = unpopulate(val, "Operation", &r.Operation) + case "name": + err = unpopulate(val, "Name", &p.Name) delete(rawMsg, key) - case "provider": - err = unpopulate(val, "Provider", &r.Provider) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) delete(rawMsg, key) - case "resource": - err = unpopulate(val, "Resource", &r.Resource) + case "type": + err = unpopulate(val, "Type", &p.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ResourceProviderOperationList. -func (r ResourceProviderOperationList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", r.NextLink) - populate(objectMap, "value", r.Value) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "type", r.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderOperationList. -func (r *ResourceProviderOperationList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) 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", r, err) @@ -1163,11 +1552,17 @@ func (r *ResourceProviderOperationList) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &r.NextLink) + case "id": + err = unpopulate(val, "ID", &r.ID) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &r.Value) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) delete(rawMsg, key) } if err != nil { @@ -1258,8 +1653,8 @@ func (s *StorageProfileUpdate) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type StorageQoSPolicy. -func (s StorageQoSPolicy) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type StorageQosPolicy. +func (s StorageQosPolicy) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "bandwidthLimit", s.BandwidthLimit) populate(objectMap, "id", s.ID) @@ -1270,8 +1665,8 @@ func (s StorageQoSPolicy) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type StorageQoSPolicy. -func (s *StorageQoSPolicy) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageQosPolicy. +func (s *StorageQosPolicy) 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", s, err) @@ -1305,16 +1700,16 @@ func (s *StorageQoSPolicy) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type StorageQoSPolicyDetails. -func (s StorageQoSPolicyDetails) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type StorageQosPolicyDetails. +func (s StorageQosPolicyDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type StorageQoSPolicyDetails. -func (s *StorageQoSPolicyDetails) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageQosPolicyDetails. +func (s *StorageQosPolicyDetails) 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", s, err) @@ -1383,22 +1778,66 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type VMMServer. -func (v VMMServer) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. +func (t *TrackedResource) 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", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMInstanceHybridIdentityMetadata. +func (v VMInstanceHybridIdentityMetadata) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "extendedLocation", v.ExtendedLocation) populate(objectMap, "id", v.ID) - populate(objectMap, "location", v.Location) populate(objectMap, "name", v.Name) populate(objectMap, "properties", v.Properties) populate(objectMap, "systemData", v.SystemData) - populate(objectMap, "tags", v.Tags) populate(objectMap, "type", v.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VMMServer. -func (v *VMMServer) UnmarshalJSON(data []byte) error { +// 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) @@ -1406,15 +1845,9 @@ func (v *VMMServer) UnmarshalJSON(data []byte) error { 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 "location": - err = unpopulate(val, "Location", &v.Location) - delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &v.Name) delete(rawMsg, key) @@ -1424,9 +1857,6 @@ func (v *VMMServer) UnmarshalJSON(data []byte) error { case "systemData": err = unpopulate(val, "SystemData", &v.SystemData) delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &v.Tags) - delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &v.Type) delete(rawMsg, key) @@ -1438,16 +1868,16 @@ func (v *VMMServer) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type VMMServerListResult. -func (v VMMServerListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type VMInstanceHybridIdentityMetadataListResult. +func (v VMInstanceHybridIdentityMetadataListResult) 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 VMMServerListResult. -func (v *VMMServerListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type VMInstanceHybridIdentityMetadataListResult. +func (v *VMInstanceHybridIdentityMetadataListResult) 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) @@ -1469,22 +1899,17 @@ func (v *VMMServerListResult) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type VMMServerProperties. -func (v VMMServerProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type VMInstanceHybridIdentityMetadataProperties. +func (v VMInstanceHybridIdentityMetadataProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "connectionStatus", v.ConnectionStatus) - populate(objectMap, "credentials", v.Credentials) - populate(objectMap, "errorMessage", v.ErrorMessage) - populate(objectMap, "fqdn", v.Fqdn) - populate(objectMap, "port", v.Port) populate(objectMap, "provisioningState", v.ProvisioningState) - populate(objectMap, "uuid", v.UUID) - populate(objectMap, "version", v.Version) + populate(objectMap, "publicKey", v.PublicKey) + populate(objectMap, "resourceUid", v.ResourceUID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VMMServerProperties. -func (v *VMMServerProperties) UnmarshalJSON(data []byte) error { +// 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) @@ -1492,60 +1917,14 @@ func (v *VMMServerProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "connectionStatus": - err = unpopulate(val, "ConnectionStatus", &v.ConnectionStatus) - delete(rawMsg, key) - case "credentials": - err = unpopulate(val, "Credentials", &v.Credentials) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) delete(rawMsg, key) - case "errorMessage": - err = unpopulate(val, "ErrorMessage", &v.ErrorMessage) + case "publicKey": + err = unpopulate(val, "PublicKey", &v.PublicKey) delete(rawMsg, key) - case "fqdn": - err = unpopulate(val, "Fqdn", &v.Fqdn) - delete(rawMsg, key) - case "port": - err = unpopulate(val, "Port", &v.Port) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) - delete(rawMsg, key) - case "uuid": - err = unpopulate(val, "UUID", &v.UUID) - delete(rawMsg, key) - case "version": - err = unpopulate(val, "Version", &v.Version) - 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 VMMServerPropertiesCredentials. -func (v VMMServerPropertiesCredentials) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "password", v.Password) - populate(objectMap, "username", v.Username) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type VMMServerPropertiesCredentials. -func (v *VMMServerPropertiesCredentials) 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 "password": - err = unpopulate(val, "Password", &v.Password) - delete(rawMsg, key) - case "username": - err = unpopulate(val, "Username", &v.Username) + case "resourceUid": + err = unpopulate(val, "ResourceUID", &v.ResourceUID) delete(rawMsg, key) } if err != nil { @@ -1567,7 +1946,7 @@ func (v VirtualDisk) MarshalJSON() ([]byte, error) { populate(objectMap, "lun", v.Lun) populate(objectMap, "maxDiskSizeGB", v.MaxDiskSizeGB) populate(objectMap, "name", v.Name) - populate(objectMap, "storageQoSPolicy", v.StorageQoSPolicy) + populate(objectMap, "storageQoSPolicy", v.StorageQosPolicy) populate(objectMap, "templateDiskId", v.TemplateDiskID) populate(objectMap, "vhdFormatType", v.VhdFormatType) populate(objectMap, "vhdType", v.VhdType) @@ -1612,7 +1991,7 @@ func (v *VirtualDisk) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Name", &v.Name) delete(rawMsg, key) case "storageQoSPolicy": - err = unpopulate(val, "StorageQoSPolicy", &v.StorageQoSPolicy) + err = unpopulate(val, "StorageQosPolicy", &v.StorageQosPolicy) delete(rawMsg, key) case "templateDiskId": err = unpopulate(val, "TemplateDiskID", &v.TemplateDiskID) @@ -1643,7 +2022,7 @@ func (v VirtualDiskUpdate) MarshalJSON() ([]byte, error) { populate(objectMap, "diskSizeGB", v.DiskSizeGB) populate(objectMap, "lun", v.Lun) populate(objectMap, "name", v.Name) - populate(objectMap, "storageQoSPolicy", v.StorageQoSPolicy) + populate(objectMap, "storageQoSPolicy", v.StorageQosPolicy) populate(objectMap, "vhdType", v.VhdType) return json.Marshal(objectMap) } @@ -1676,7 +2055,7 @@ func (v *VirtualDiskUpdate) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Name", &v.Name) delete(rawMsg, key) case "storageQoSPolicy": - err = unpopulate(val, "StorageQoSPolicy", &v.StorageQoSPolicy) + err = unpopulate(val, "StorageQosPolicy", &v.StorageQosPolicy) delete(rawMsg, key) case "vhdType": err = unpopulate(val, "VhdType", &v.VhdType) @@ -1689,22 +2068,16 @@ func (v *VirtualDiskUpdate) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type VirtualMachine. -func (v VirtualMachine) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineCreateCheckpoint. +func (v VirtualMachineCreateCheckpoint) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "extendedLocation", v.ExtendedLocation) - populate(objectMap, "id", v.ID) - populate(objectMap, "location", v.Location) + populate(objectMap, "description", v.Description) populate(objectMap, "name", v.Name) - populate(objectMap, "properties", v.Properties) - populate(objectMap, "systemData", v.SystemData) - populate(objectMap, "tags", v.Tags) - populate(objectMap, "type", v.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachine. -func (v *VirtualMachine) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineCreateCheckpoint. +func (v *VirtualMachineCreateCheckpoint) 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) @@ -1712,29 +2085,38 @@ func (v *VirtualMachine) UnmarshalJSON(data []byte) error { 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 "location": - err = unpopulate(val, "Location", &v.Location) + case "description": + err = unpopulate(val, "Description", &v.Description) 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 "tags": - err = unpopulate(val, "Tags", &v.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &v.Type) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineDeleteCheckpoint. +func (v VirtualMachineDeleteCheckpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", v.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineDeleteCheckpoint. +func (v *VirtualMachineDeleteCheckpoint) 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) } if err != nil { @@ -1744,16 +2126,20 @@ func (v *VirtualMachine) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type VirtualMachineCreateCheckpoint. -func (v VirtualMachineCreateCheckpoint) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineInstance. +func (v VirtualMachineInstance) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "description", v.Description) + 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 VirtualMachineCreateCheckpoint. -func (v *VirtualMachineCreateCheckpoint) UnmarshalJSON(data []byte) error { +// 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) @@ -1761,12 +2147,24 @@ func (v *VirtualMachineCreateCheckpoint) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "description": - err = unpopulate(val, "Description", &v.Description) + 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) @@ -1775,15 +2173,16 @@ func (v *VirtualMachineCreateCheckpoint) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type VirtualMachineDeleteCheckpoint. -func (v VirtualMachineDeleteCheckpoint) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineInstanceListResult. +func (v VirtualMachineInstanceListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", v.ID) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineDeleteCheckpoint. -func (v *VirtualMachineDeleteCheckpoint) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineInstanceListResult. +func (v *VirtualMachineInstanceListResult) 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) @@ -1791,8 +2190,11 @@ func (v *VirtualMachineDeleteCheckpoint) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &v.ID) + 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 { @@ -1802,24 +2204,22 @@ func (v *VirtualMachineDeleteCheckpoint) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type VirtualMachineInventoryItem. -func (v VirtualMachineInventoryItem) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineInstanceProperties. +func (v VirtualMachineInstanceProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "cloud", v.Cloud) - populate(objectMap, "ipAddresses", v.IPAddresses) - populate(objectMap, "inventoryItemName", v.InventoryItemName) - objectMap["inventoryType"] = InventoryTypeVirtualMachine - populate(objectMap, "managedResourceId", v.ManagedResourceID) - populate(objectMap, "osName", v.OSName) - populate(objectMap, "osType", v.OSType) + populate(objectMap, "availabilitySets", v.AvailabilitySets) + populate(objectMap, "hardwareProfile", v.HardwareProfile) + populate(objectMap, "infrastructureProfile", v.InfrastructureProfile) + populate(objectMap, "networkProfile", v.NetworkProfile) + populate(objectMap, "osProfile", v.OSProfile) populate(objectMap, "powerState", v.PowerState) populate(objectMap, "provisioningState", v.ProvisioningState) - populate(objectMap, "uuid", v.UUID) + populate(objectMap, "storageProfile", v.StorageProfile) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineInventoryItem. -func (v *VirtualMachineInventoryItem) UnmarshalJSON(data []byte) error { +// 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) @@ -1827,26 +2227,20 @@ func (v *VirtualMachineInventoryItem) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "cloud": - err = unpopulate(val, "Cloud", &v.Cloud) - delete(rawMsg, key) - case "ipAddresses": - err = unpopulate(val, "IPAddresses", &v.IPAddresses) - delete(rawMsg, key) - case "inventoryItemName": - err = unpopulate(val, "InventoryItemName", &v.InventoryItemName) + case "availabilitySets": + err = unpopulate(val, "AvailabilitySets", &v.AvailabilitySets) delete(rawMsg, key) - case "inventoryType": - err = unpopulate(val, "InventoryType", &v.InventoryType) + case "hardwareProfile": + err = unpopulate(val, "HardwareProfile", &v.HardwareProfile) delete(rawMsg, key) - case "managedResourceId": - err = unpopulate(val, "ManagedResourceID", &v.ManagedResourceID) + case "infrastructureProfile": + err = unpopulate(val, "InfrastructureProfile", &v.InfrastructureProfile) delete(rawMsg, key) - case "osName": - err = unpopulate(val, "OSName", &v.OSName) + case "networkProfile": + err = unpopulate(val, "NetworkProfile", &v.NetworkProfile) delete(rawMsg, key) - case "osType": - err = unpopulate(val, "OSType", &v.OSType) + case "osProfile": + err = unpopulate(val, "OSProfile", &v.OSProfile) delete(rawMsg, key) case "powerState": err = unpopulate(val, "PowerState", &v.PowerState) @@ -1854,8 +2248,8 @@ func (v *VirtualMachineInventoryItem) UnmarshalJSON(data []byte) error { case "provisioningState": err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) delete(rawMsg, key) - case "uuid": - err = unpopulate(val, "UUID", &v.UUID) + case "storageProfile": + err = unpopulate(val, "StorageProfile", &v.StorageProfile) delete(rawMsg, key) } if err != nil { @@ -1865,16 +2259,15 @@ func (v *VirtualMachineInventoryItem) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type VirtualMachineListResult. -func (v VirtualMachineListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineInstanceUpdate. +func (v VirtualMachineInstanceUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", v.NextLink) - populate(objectMap, "value", v.Value) + populate(objectMap, "properties", v.Properties) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineListResult. -func (v *VirtualMachineListResult) UnmarshalJSON(data []byte) error { +// 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) @@ -1882,11 +2275,8 @@ func (v *VirtualMachineListResult) UnmarshalJSON(data []byte) error { 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) + case "properties": + err = unpopulate(val, "Properties", &v.Properties) delete(rawMsg, key) } if err != nil { @@ -1896,30 +2286,19 @@ func (v *VirtualMachineListResult) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type VirtualMachineProperties. -func (v VirtualMachineProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineInstanceUpdateProperties. +func (v VirtualMachineInstanceUpdateProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "availabilitySets", v.AvailabilitySets) - populate(objectMap, "checkpointType", v.CheckpointType) - populate(objectMap, "checkpoints", v.Checkpoints) - populate(objectMap, "cloudId", v.CloudID) - populate(objectMap, "generation", v.Generation) populate(objectMap, "hardwareProfile", v.HardwareProfile) - populate(objectMap, "inventoryItemId", v.InventoryItemID) + populate(objectMap, "infrastructureProfile", v.InfrastructureProfile) populate(objectMap, "networkProfile", v.NetworkProfile) - populate(objectMap, "osProfile", v.OSProfile) - populate(objectMap, "powerState", v.PowerState) - populate(objectMap, "provisioningState", v.ProvisioningState) populate(objectMap, "storageProfile", v.StorageProfile) - populate(objectMap, "templateId", v.TemplateID) - populate(objectMap, "uuid", v.UUID) - populate(objectMap, "vmName", v.VMName) - populate(objectMap, "vmmServerId", v.VmmServerID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineProperties. -func (v *VirtualMachineProperties) UnmarshalJSON(data []byte) error { +// 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) @@ -1930,51 +2309,93 @@ func (v *VirtualMachineProperties) UnmarshalJSON(data []byte) error { case "availabilitySets": err = unpopulate(val, "AvailabilitySets", &v.AvailabilitySets) delete(rawMsg, key) - case "checkpointType": - err = unpopulate(val, "CheckpointType", &v.CheckpointType) - delete(rawMsg, key) - case "checkpoints": - err = unpopulate(val, "Checkpoints", &v.Checkpoints) - delete(rawMsg, key) - case "cloudId": - err = unpopulate(val, "CloudID", &v.CloudID) - delete(rawMsg, key) - case "generation": - err = unpopulate(val, "Generation", &v.Generation) - delete(rawMsg, key) case "hardwareProfile": err = unpopulate(val, "HardwareProfile", &v.HardwareProfile) delete(rawMsg, key) - case "inventoryItemId": - err = unpopulate(val, "InventoryItemID", &v.InventoryItemID) + 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) + case "storageProfile": + err = unpopulate(val, "StorageProfile", &v.StorageProfile) delete(rawMsg, key) - case "powerState": - err = unpopulate(val, "PowerState", &v.PowerState) + } + 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, "biosGuid", v.BiosGUID) + populate(objectMap, "cloud", v.Cloud) + populate(objectMap, "ipAddresses", v.IPAddresses) + populate(objectMap, "inventoryItemName", v.InventoryItemName) + objectMap["inventoryType"] = InventoryTypeVirtualMachine + populate(objectMap, "managedMachineResourceId", v.ManagedMachineResourceID) + populate(objectMap, "managedResourceId", v.ManagedResourceID) + populate(objectMap, "osName", v.OSName) + populate(objectMap, "osType", v.OSType) + populate(objectMap, "osVersion", v.OSVersion) + populate(objectMap, "powerState", v.PowerState) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "uuid", v.UUID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineInventoryItem. +func (v *VirtualMachineInventoryItem) 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 "biosGuid": + err = unpopulate(val, "BiosGUID", &v.BiosGUID) delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) + case "cloud": + err = unpopulate(val, "Cloud", &v.Cloud) delete(rawMsg, key) - case "storageProfile": - err = unpopulate(val, "StorageProfile", &v.StorageProfile) + case "ipAddresses": + err = unpopulate(val, "IPAddresses", &v.IPAddresses) delete(rawMsg, key) - case "templateId": - err = unpopulate(val, "TemplateID", &v.TemplateID) + case "inventoryItemName": + err = unpopulate(val, "InventoryItemName", &v.InventoryItemName) + delete(rawMsg, key) + case "inventoryType": + err = unpopulate(val, "InventoryType", &v.InventoryType) + delete(rawMsg, key) + case "managedMachineResourceId": + err = unpopulate(val, "ManagedMachineResourceID", &v.ManagedMachineResourceID) + delete(rawMsg, key) + case "managedResourceId": + err = unpopulate(val, "ManagedResourceID", &v.ManagedResourceID) + delete(rawMsg, key) + case "osName": + err = unpopulate(val, "OSName", &v.OSName) + delete(rawMsg, key) + case "osType": + err = unpopulate(val, "OSType", &v.OSType) + delete(rawMsg, key) + case "osVersion": + err = unpopulate(val, "OSVersion", &v.OSVersion) + 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 "uuid": err = unpopulate(val, "UUID", &v.UUID) delete(rawMsg, key) - case "vmName": - err = unpopulate(val, "VMName", &v.VMName) - delete(rawMsg, key) - case "vmmServerId": - err = unpopulate(val, "VmmServerID", &v.VmmServerID) - delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", v, err) @@ -2250,16 +2671,15 @@ func (v *VirtualMachineTemplateProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type VirtualMachineUpdate. -func (v VirtualMachineUpdate) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineTemplateTagsUpdate. +func (v VirtualMachineTemplateTagsUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "properties", v.Properties) populate(objectMap, "tags", v.Tags) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineUpdate. -func (v *VirtualMachineUpdate) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineTemplateTagsUpdate. +func (v *VirtualMachineTemplateTagsUpdate) 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) @@ -2267,9 +2687,6 @@ func (v *VirtualMachineUpdate) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "properties": - err = unpopulate(val, "Properties", &v.Properties) - delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &v.Tags) delete(rawMsg, key) @@ -2281,45 +2698,6 @@ func (v *VirtualMachineUpdate) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type VirtualMachineUpdateProperties. -func (v VirtualMachineUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "availabilitySets", v.AvailabilitySets) - 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 VirtualMachineUpdateProperties. -func (v *VirtualMachineUpdateProperties) 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 "availabilitySets": - err = unpopulate(val, "AvailabilitySets", &v.AvailabilitySets) - delete(rawMsg, 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 VirtualNetwork. func (v VirtualNetwork) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2492,6 +2870,232 @@ func (v *VirtualNetworkProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworkTagsUpdate. +func (v VirtualNetworkTagsUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", v.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworkTagsUpdate. +func (v *VirtualNetworkTagsUpdate) 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 "tags": + err = unpopulate(val, "Tags", &v.Tags) + 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 VmmCredential. +func (v VmmCredential) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "password", v.Password) + populate(objectMap, "username", v.Username) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VmmCredential. +func (v *VmmCredential) 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 "password": + err = unpopulate(val, "Password", &v.Password) + delete(rawMsg, key) + case "username": + err = unpopulate(val, "Username", &v.Username) + 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 VmmServer. +func (v VmmServer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "extendedLocation", v.ExtendedLocation) + populate(objectMap, "id", v.ID) + populate(objectMap, "location", v.Location) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "systemData", v.SystemData) + populate(objectMap, "tags", v.Tags) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VmmServer. +func (v *VmmServer) 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 "location": + err = unpopulate(val, "Location", &v.Location) + 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 "tags": + err = unpopulate(val, "Tags", &v.Tags) + 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 VmmServerListResult. +func (v VmmServerListResult) 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 VmmServerListResult. +func (v *VmmServerListResult) 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 VmmServerProperties. +func (v VmmServerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "connectionStatus", v.ConnectionStatus) + populate(objectMap, "credentials", v.Credentials) + populate(objectMap, "errorMessage", v.ErrorMessage) + populate(objectMap, "fqdn", v.Fqdn) + populate(objectMap, "port", v.Port) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "uuid", v.UUID) + populate(objectMap, "version", v.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VmmServerProperties. +func (v *VmmServerProperties) 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 "connectionStatus": + err = unpopulate(val, "ConnectionStatus", &v.ConnectionStatus) + delete(rawMsg, key) + case "credentials": + err = unpopulate(val, "Credentials", &v.Credentials) + delete(rawMsg, key) + case "errorMessage": + err = unpopulate(val, "ErrorMessage", &v.ErrorMessage) + delete(rawMsg, key) + case "fqdn": + err = unpopulate(val, "Fqdn", &v.Fqdn) + delete(rawMsg, key) + case "port": + err = unpopulate(val, "Port", &v.Port) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) + delete(rawMsg, key) + case "uuid": + err = unpopulate(val, "UUID", &v.UUID) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &v.Version) + 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 VmmServerTagsUpdate. +func (v VmmServerTagsUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", v.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VmmServerTagsUpdate. +func (v *VmmServerTagsUpdate) 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 "tags": + err = unpopulate(val, "Tags", &v.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + func populate(m map[string]any, k string, v any) { if v == nil { return @@ -2502,8 +3106,18 @@ func populate(m map[string]any, k string, v any) { } } +func populateAny(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else { + m[k] = v + } +} + func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/scvmm/armscvmm/operations_client.go b/sdk/resourcemanager/scvmm/armscvmm/operations_client.go index c42f983da8a5..71a20790552f 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/operations_client.go +++ b/sdk/resourcemanager/scvmm/armscvmm/operations_client.go @@ -37,9 +37,9 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO return client, nil } -// NewListPager - Returns list of all operations. +// NewListPager - List the operations for the provider // -// Generated from API version 2020-06-05-preview +// Generated from API version 2024-06-01 // - 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]{ @@ -72,7 +72,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -81,7 +81,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * // listHandleResponse handles the List response. func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { result := OperationsClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ResourceProviderOperationList); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { return OperationsClientListResponse{}, err } return result, nil diff --git a/sdk/resourcemanager/scvmm/armscvmm/operations_client_example_test.go b/sdk/resourcemanager/scvmm/armscvmm/operations_client_example_test.go deleted file mode 100644 index fb8b2985d7c5..000000000000 --- a/sdk/resourcemanager/scvmm/armscvmm/operations_client_example_test.go +++ /dev/null @@ -1,181 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// 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 armscvmm_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/scvmm/armscvmm" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-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 := armscvmm.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.ResourceProviderOperationList = armscvmm.ResourceProviderOperationList{ - // Value: []*armscvmm.ResourceProviderOperation{ - // { - // Name: to.Ptr("Microsoft.ScVmm/VmmServers/Read"), - // Display: &armscvmm.ResourceProviderOperationDisplay{ - // Description: to.Ptr("Gets/List the VmmServer resource data."), - // Operation: to.Ptr("Gets/List VmmServer resources."), - // Provider: to.Ptr("Microsoft.ScVmm resource provider"), - // Resource: to.Ptr("VmmServers"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ScVmm/VmmServers/Write"), - // Display: &armscvmm.ResourceProviderOperationDisplay{ - // Description: to.Ptr("Read VmmServer."), - // Operation: to.Ptr("Create or Update VmmServer resource."), - // Provider: to.Ptr("Microsoft.ScVmm resource provider"), - // Resource: to.Ptr("VmmServers"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ScVmm/VmmServers/Delete"), - // Display: &armscvmm.ResourceProviderOperationDisplay{ - // Description: to.Ptr("Deletes the VmmServer resource."), - // Operation: to.Ptr("Deletes the VmmServer resource."), - // Provider: to.Ptr("Microsoft.ScVmm resource provider"), - // Resource: to.Ptr("VmmServers"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ScVmm/Clouds/Read"), - // Display: &armscvmm.ResourceProviderOperationDisplay{ - // Description: to.Ptr("Gets/List the Cloud resource data."), - // Operation: to.Ptr("Gets/List Cloud resources."), - // Provider: to.Ptr("Microsoft.ScVmm resource provider"), - // Resource: to.Ptr("Clouds"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ScVmm/Clouds/Write"), - // Display: &armscvmm.ResourceProviderOperationDisplay{ - // Description: to.Ptr("Create or Update Cloud resource data."), - // Operation: to.Ptr("Create or Update Cloud resource."), - // Provider: to.Ptr("Microsoft.ScVmm resource provider"), - // Resource: to.Ptr("Clouds"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ScVmm/Clouds/Delete"), - // Display: &armscvmm.ResourceProviderOperationDisplay{ - // Description: to.Ptr("Deletes the Cloud resource."), - // Operation: to.Ptr("Deletes the Cloud resource."), - // Provider: to.Ptr("Microsoft.ScVmm resource provider"), - // Resource: to.Ptr("Clouds"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ScVmm/VirtualNetworks/Read"), - // Display: &armscvmm.ResourceProviderOperationDisplay{ - // Description: to.Ptr("Gets/List the VirtualNetwork resource data."), - // Operation: to.Ptr("Gets/List VirtualNetwork resources."), - // Provider: to.Ptr("Microsoft.ScVmm resource provider"), - // Resource: to.Ptr("VirtualNetworks"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ScVmm/VirtualNetworks/Write"), - // Display: &armscvmm.ResourceProviderOperationDisplay{ - // Description: to.Ptr("Create or Update VirtualNetwork resource data."), - // Operation: to.Ptr("Create or Update VirtualNetwork resource."), - // Provider: to.Ptr("Microsoft.ScVmm resource provider"), - // Resource: to.Ptr("VirtualNetworks"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ScVmm/VirtualNetworks/Delete"), - // Display: &armscvmm.ResourceProviderOperationDisplay{ - // Description: to.Ptr("Deletes the VirtualNetwork resource."), - // Operation: to.Ptr("Deletes the VirtualNetwork resource."), - // Provider: to.Ptr("Microsoft.ScVmm resource provider"), - // Resource: to.Ptr("VirtualNetworks"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ScVmm/VirtualMachineTemplates/Read"), - // Display: &armscvmm.ResourceProviderOperationDisplay{ - // Description: to.Ptr("Gets/List the VirtualMachineTemplate resource data."), - // Operation: to.Ptr("Gets/List VirtualMachineTemplate resources."), - // Provider: to.Ptr("Microsoft.ScVmm resource provider"), - // Resource: to.Ptr("VirtualMachineTemplates"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ScVmm/VirtualMachineTemplates/Write"), - // Display: &armscvmm.ResourceProviderOperationDisplay{ - // Description: to.Ptr("Create or Update VirtualMachineTemplate resource data."), - // Operation: to.Ptr("Create or Update VirtualMachineTemplate resource."), - // Provider: to.Ptr("Microsoft.ScVmm resource provider"), - // Resource: to.Ptr("VirtualMachineTemplates"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ScVmm/VirtualMachineTemplates/Delete"), - // Display: &armscvmm.ResourceProviderOperationDisplay{ - // Description: to.Ptr("Deletes the VirtualMachineTemplate resource."), - // Operation: to.Ptr("Deletes the VirtualMachineTemplate resource."), - // Provider: to.Ptr("Microsoft.ScVmm resource provider"), - // Resource: to.Ptr("VirtualMachineTemplates"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ScVmm/VirtualMachines/Read"), - // Display: &armscvmm.ResourceProviderOperationDisplay{ - // Description: to.Ptr("Gets/List the VirtualMachine resource data."), - // Operation: to.Ptr("Gets/List VirtualMachine resources."), - // Provider: to.Ptr("Microsoft.ScVmm resource provider"), - // Resource: to.Ptr("VirtualMachines"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ScVmm/VirtualMachines/Write"), - // Display: &armscvmm.ResourceProviderOperationDisplay{ - // Description: to.Ptr("Create or Update VirtualMachine resource data."), - // Operation: to.Ptr("Create or Update VirtualMachine resource."), - // Provider: to.Ptr("Microsoft.ScVmm resource provider"), - // Resource: to.Ptr("VirtualMachines"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.ScVmm/VirtualMachines/Delete"), - // Display: &armscvmm.ResourceProviderOperationDisplay{ - // Description: to.Ptr("Deletes the VirtualMachine resource."), - // Operation: to.Ptr("Deletes the VirtualMachine resource."), - // Provider: to.Ptr("Microsoft.ScVmm resource provider"), - // Resource: to.Ptr("VirtualMachines"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/scvmm/armscvmm/options.go b/sdk/resourcemanager/scvmm/armscvmm/options.go index 81f1308df851..b22dfafc9139 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/options.go +++ b/sdk/resourcemanager/scvmm/armscvmm/options.go @@ -17,8 +17,8 @@ type AvailabilitySetsClientBeginCreateOrUpdateOptions struct { // AvailabilitySetsClientBeginDeleteOptions contains the optional parameters for the AvailabilitySetsClient.BeginDelete method. type AvailabilitySetsClientBeginDeleteOptions struct { - // Forces the resource to be deleted from azure. The corresponding CR would be attempted to be deleted too. - Force *bool + // Forces the resource to be deleted. + Force *ForceDelete // Resumes the LRO from the provided token. ResumeToken string @@ -55,8 +55,8 @@ type CloudsClientBeginCreateOrUpdateOptions struct { // CloudsClientBeginDeleteOptions contains the optional parameters for the CloudsClient.BeginDelete method. type CloudsClientBeginDeleteOptions struct { - // Forces the resource to be deleted from azure. The corresponding CR would be attempted to be deleted too. - Force *bool + // Forces the resource to be deleted. + Force *ForceDelete // Resumes the LRO from the provided token. ResumeToken string @@ -85,10 +85,31 @@ type CloudsClientListBySubscriptionOptions 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 +} + +// GuestAgentsClientDeleteOptions contains the optional parameters for the GuestAgentsClient.Delete method. +type GuestAgentsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// GuestAgentsClientGetOptions contains the optional parameters for the GuestAgentsClient.Get method. +type GuestAgentsClientGetOptions struct { + // placeholder for future optional parameters +} + +// GuestAgentsClientListByVirtualMachineInstanceOptions contains the optional parameters for the GuestAgentsClient.NewListByVirtualMachineInstancePager +// method. +type GuestAgentsClientListByVirtualMachineInstanceOptions struct { + // placeholder for future optional parameters +} + // InventoryItemsClientCreateOptions contains the optional parameters for the InventoryItemsClient.Create method. type InventoryItemsClientCreateOptions struct { - // Request payload. - Body *InventoryItem + // placeholder for future optional parameters } // InventoryItemsClientDeleteOptions contains the optional parameters for the InventoryItemsClient.Delete method. @@ -101,9 +122,9 @@ type InventoryItemsClientGetOptions struct { // placeholder for future optional parameters } -// InventoryItemsClientListByVMMServerOptions contains the optional parameters for the InventoryItemsClient.NewListByVMMServerPager +// InventoryItemsClientListByVmmServerOptions contains the optional parameters for the InventoryItemsClient.NewListByVmmServerPager // method. -type InventoryItemsClientListByVMMServerOptions struct { +type InventoryItemsClientListByVmmServerOptions struct { // placeholder for future optional parameters } @@ -112,137 +133,136 @@ type OperationsClientListOptions struct { // placeholder for future optional parameters } -// VirtualMachineTemplatesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginCreateOrUpdate +// VMInstanceHybridIdentityMetadatasClientGetOptions contains the optional parameters for the VMInstanceHybridIdentityMetadatasClient.Get // method. -type VirtualMachineTemplatesClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string +type VMInstanceHybridIdentityMetadatasClientGetOptions struct { + // placeholder for future optional parameters } -// VirtualMachineTemplatesClientBeginDeleteOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginDelete +// VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceOptions contains the optional parameters for the VMInstanceHybridIdentityMetadatasClient.NewListByVirtualMachineInstancePager // method. -type VirtualMachineTemplatesClientBeginDeleteOptions struct { - // Forces the resource to be deleted from azure. The corresponding CR would be attempted to be deleted too. - Force *bool +type VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceOptions struct { + // placeholder for future optional parameters +} +// VirtualMachineInstancesClientBeginCreateCheckpointOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginCreateCheckpoint +// method. +type VirtualMachineInstancesClientBeginCreateCheckpointOptions struct { // Resumes the LRO from the provided token. ResumeToken string } -// VirtualMachineTemplatesClientBeginUpdateOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginUpdate +// VirtualMachineInstancesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginCreateOrUpdate // method. -type VirtualMachineTemplatesClientBeginUpdateOptions struct { +type VirtualMachineInstancesClientBeginCreateOrUpdateOptions struct { // 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 +// VirtualMachineInstancesClientBeginDeleteCheckpointOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginDeleteCheckpoint // method. -type VirtualMachineTemplatesClientListByResourceGroupOptions struct { - // placeholder for future optional parameters +type VirtualMachineInstancesClientBeginDeleteCheckpointOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } -// VirtualMachineTemplatesClientListBySubscriptionOptions contains the optional parameters for the VirtualMachineTemplatesClient.NewListBySubscriptionPager +// VirtualMachineInstancesClientBeginDeleteOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginDelete // method. -type VirtualMachineTemplatesClientListBySubscriptionOptions struct { - // placeholder for future optional parameters -} +type VirtualMachineInstancesClientBeginDeleteOptions struct { + // Whether to disable the VM from azure and also delete it from Vmm. + DeleteFromHost *DeleteFromHost -// VirtualMachinesClientBeginCreateCheckpointOptions contains the optional parameters for the VirtualMachinesClient.BeginCreateCheckpoint -// method. -type VirtualMachinesClientBeginCreateCheckpointOptions struct { - // Virtualmachine create checkpoint action payload. - Body *VirtualMachineCreateCheckpoint + // Forces the resource to be deleted. + Force *ForceDelete // Resumes the LRO from the provided token. ResumeToken string } -// VirtualMachinesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginCreateOrUpdate +// VirtualMachineInstancesClientBeginRestartOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginRestart // method. -type VirtualMachinesClientBeginCreateOrUpdateOptions struct { +type VirtualMachineInstancesClientBeginRestartOptions struct { // Resumes the LRO from the provided token. ResumeToken string } -// VirtualMachinesClientBeginDeleteCheckpointOptions contains the optional parameters for the VirtualMachinesClient.BeginDeleteCheckpoint +// VirtualMachineInstancesClientBeginRestoreCheckpointOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginRestoreCheckpoint // method. -type VirtualMachinesClientBeginDeleteCheckpointOptions struct { - // Virtualmachine delete checkpoint action payload. - Body *VirtualMachineDeleteCheckpoint - +type VirtualMachineInstancesClientBeginRestoreCheckpointOptions struct { // Resumes the LRO from the provided token. ResumeToken string } -// VirtualMachinesClientBeginDeleteOptions contains the optional parameters for the VirtualMachinesClient.BeginDelete method. -type VirtualMachinesClientBeginDeleteOptions struct { - // Forces the resource to be deleted from azure. The corresponding CR would be attempted to be deleted too. - Force *bool - +// VirtualMachineInstancesClientBeginStartOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginStart +// method. +type VirtualMachineInstancesClientBeginStartOptions struct { // 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 } -// VirtualMachinesClientBeginRestartOptions contains the optional parameters for the VirtualMachinesClient.BeginRestart method. -type VirtualMachinesClientBeginRestartOptions struct { +// VirtualMachineInstancesClientBeginStopOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginStop +// method. +type VirtualMachineInstancesClientBeginStopOptions struct { // Resumes the LRO from the provided token. ResumeToken string } -// VirtualMachinesClientBeginRestoreCheckpointOptions contains the optional parameters for the VirtualMachinesClient.BeginRestoreCheckpoint +// VirtualMachineInstancesClientBeginUpdateOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginUpdate // method. -type VirtualMachinesClientBeginRestoreCheckpointOptions struct { - // Virtualmachine restore checkpoint action payload. - Body *VirtualMachineRestoreCheckpoint - +type VirtualMachineInstancesClientBeginUpdateOptions struct { // Resumes the LRO from the provided token. ResumeToken string } -// VirtualMachinesClientBeginStartOptions contains the optional parameters for the VirtualMachinesClient.BeginStart method. -type VirtualMachinesClientBeginStartOptions struct { +// 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 +} + +// VirtualMachineTemplatesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginCreateOrUpdate +// method. +type VirtualMachineTemplatesClientBeginCreateOrUpdateOptions 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 +// VirtualMachineTemplatesClientBeginDeleteOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginDelete +// method. +type VirtualMachineTemplatesClientBeginDeleteOptions struct { + // Forces the resource to be deleted. + Force *ForceDelete // Resumes the LRO from the provided token. ResumeToken string } -// VirtualMachinesClientBeginUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginUpdate method. -type VirtualMachinesClientBeginUpdateOptions struct { +// VirtualMachineTemplatesClientBeginUpdateOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginUpdate +// method. +type VirtualMachineTemplatesClientBeginUpdateOptions struct { // Resumes the LRO from the provided token. ResumeToken string } -// VirtualMachinesClientGetOptions contains the optional parameters for the VirtualMachinesClient.Get method. -type VirtualMachinesClientGetOptions struct { +// VirtualMachineTemplatesClientGetOptions contains the optional parameters for the VirtualMachineTemplatesClient.Get method. +type VirtualMachineTemplatesClientGetOptions struct { // placeholder for future optional parameters } -// VirtualMachinesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachinesClient.NewListByResourceGroupPager +// VirtualMachineTemplatesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachineTemplatesClient.NewListByResourceGroupPager // method. -type VirtualMachinesClientListByResourceGroupOptions struct { +type VirtualMachineTemplatesClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// VirtualMachinesClientListBySubscriptionOptions contains the optional parameters for the VirtualMachinesClient.NewListBySubscriptionPager +// VirtualMachineTemplatesClientListBySubscriptionOptions contains the optional parameters for the VirtualMachineTemplatesClient.NewListBySubscriptionPager // method. -type VirtualMachinesClientListBySubscriptionOptions struct { +type VirtualMachineTemplatesClientListBySubscriptionOptions struct { // placeholder for future optional parameters } @@ -255,8 +275,8 @@ type VirtualNetworksClientBeginCreateOrUpdateOptions struct { // VirtualNetworksClientBeginDeleteOptions contains the optional parameters for the VirtualNetworksClient.BeginDelete method. type VirtualNetworksClientBeginDeleteOptions struct { - // Forces the resource to be deleted from azure. The corresponding CR would be attempted to be deleted too. - Force *bool + // Forces the resource to be deleted. + Force *ForceDelete // Resumes the LRO from the provided token. ResumeToken string @@ -294,8 +314,8 @@ type VmmServersClientBeginCreateOrUpdateOptions struct { // VmmServersClientBeginDeleteOptions contains the optional parameters for the VmmServersClient.BeginDelete method. type VmmServersClientBeginDeleteOptions struct { - // Forces the resource to be deleted from azure. The corresponding CR would be attempted to be deleted too. - Force *bool + // Forces the resource to be deleted. + Force *ForceDelete // Resumes the LRO from the provided token. ResumeToken string diff --git a/sdk/resourcemanager/scvmm/armscvmm/polymorphic_helpers.go b/sdk/resourcemanager/scvmm/armscvmm/polymorphic_helpers.go index 6bd2cc52b2ef..336d9c45d58d 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/polymorphic_helpers.go +++ b/sdk/resourcemanager/scvmm/armscvmm/polymorphic_helpers.go @@ -11,7 +11,7 @@ package armscvmm import "encoding/json" func unmarshalInventoryItemPropertiesClassification(rawMsg json.RawMessage) (InventoryItemPropertiesClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any diff --git a/sdk/resourcemanager/scvmm/armscvmm/response_types.go b/sdk/resourcemanager/scvmm/armscvmm/responses.go similarity index 61% rename from sdk/resourcemanager/scvmm/armscvmm/response_types.go rename to sdk/resourcemanager/scvmm/armscvmm/responses.go index 424c9d14682c..1b7d0d73a597 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/response_types.go +++ b/sdk/resourcemanager/scvmm/armscvmm/responses.go @@ -27,13 +27,13 @@ type AvailabilitySetsClientGetResponse struct { // AvailabilitySetsClientListByResourceGroupResponse contains the response from method AvailabilitySetsClient.NewListByResourceGroupPager. type AvailabilitySetsClientListByResourceGroupResponse struct { - // List of AvailabilitySets. + // The response of a AvailabilitySet list operation. AvailabilitySetListResult } // AvailabilitySetsClientListBySubscriptionResponse contains the response from method AvailabilitySetsClient.NewListBySubscriptionPager. type AvailabilitySetsClientListBySubscriptionResponse struct { - // List of AvailabilitySets. + // The response of a AvailabilitySet list operation. AvailabilitySetListResult } @@ -62,13 +62,13 @@ type CloudsClientGetResponse struct { // CloudsClientListByResourceGroupResponse contains the response from method CloudsClient.NewListByResourceGroupPager. type CloudsClientListByResourceGroupResponse struct { - // List of Clouds. + // The response of a Cloud list operation. CloudListResult } // CloudsClientListBySubscriptionResponse contains the response from method CloudsClient.NewListBySubscriptionPager. type CloudsClientListBySubscriptionResponse struct { - // List of Clouds. + // The response of a Cloud list operation. CloudListResult } @@ -78,6 +78,29 @@ type CloudsClientUpdateResponse struct { Cloud } +// GuestAgentsClientCreateResponse contains the response from method GuestAgentsClient.BeginCreate. +type GuestAgentsClientCreateResponse struct { + // Defines the GuestAgent. + GuestAgent +} + +// GuestAgentsClientDeleteResponse contains the response from method GuestAgentsClient.Delete. +type GuestAgentsClientDeleteResponse struct { + // placeholder for future response values +} + +// GuestAgentsClientGetResponse contains the response from method GuestAgentsClient.Get. +type GuestAgentsClientGetResponse struct { + // Defines the GuestAgent. + GuestAgent +} + +// GuestAgentsClientListByVirtualMachineInstanceResponse contains the response from method GuestAgentsClient.NewListByVirtualMachineInstancePager. +type GuestAgentsClientListByVirtualMachineInstanceResponse struct { + // The response of a GuestAgent list operation. + GuestAgentListResult +} + // InventoryItemsClientCreateResponse contains the response from method InventoryItemsClient.Create. type InventoryItemsClientCreateResponse struct { // Defines the inventory item. @@ -95,116 +118,122 @@ type InventoryItemsClientGetResponse struct { InventoryItem } -// InventoryItemsClientListByVMMServerResponse contains the response from method InventoryItemsClient.NewListByVMMServerPager. -type InventoryItemsClientListByVMMServerResponse struct { - // List of InventoryItems. - InventoryItemsList +// InventoryItemsClientListByVmmServerResponse contains the response from method InventoryItemsClient.NewListByVmmServerPager. +type InventoryItemsClientListByVmmServerResponse struct { + // The response of a InventoryItem list operation. + InventoryItemListResult } // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { - // Results of the request to list operations. - ResourceProviderOperationList + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + OperationListResult } -// VirtualMachineTemplatesClientCreateOrUpdateResponse contains the response from method VirtualMachineTemplatesClient.BeginCreateOrUpdate. -type VirtualMachineTemplatesClientCreateOrUpdateResponse struct { - // The VirtualMachineTemplates resource definition. - VirtualMachineTemplate +// VMInstanceHybridIdentityMetadatasClientGetResponse contains the response from method VMInstanceHybridIdentityMetadatasClient.Get. +type VMInstanceHybridIdentityMetadatasClientGetResponse struct { + // Defines the HybridIdentityMetadata. + VMInstanceHybridIdentityMetadata } -// VirtualMachineTemplatesClientDeleteResponse contains the response from method VirtualMachineTemplatesClient.BeginDelete. -type VirtualMachineTemplatesClientDeleteResponse struct { +// VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceResponse contains the response from method VMInstanceHybridIdentityMetadatasClient.NewListByVirtualMachineInstancePager. +type VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceResponse struct { + // The response of a VmInstanceHybridIdentityMetadata list operation. + VMInstanceHybridIdentityMetadataListResult +} + +// VirtualMachineInstancesClientCreateCheckpointResponse contains the response from method VirtualMachineInstancesClient.BeginCreateCheckpoint. +type VirtualMachineInstancesClientCreateCheckpointResponse struct { // placeholder for future response values } -// VirtualMachineTemplatesClientGetResponse contains the response from method VirtualMachineTemplatesClient.Get. -type VirtualMachineTemplatesClientGetResponse struct { - // The VirtualMachineTemplates resource definition. - VirtualMachineTemplate +// VirtualMachineInstancesClientCreateOrUpdateResponse contains the response from method VirtualMachineInstancesClient.BeginCreateOrUpdate. +type VirtualMachineInstancesClientCreateOrUpdateResponse struct { + // Define the virtualMachineInstance. + VirtualMachineInstance } -// VirtualMachineTemplatesClientListByResourceGroupResponse contains the response from method VirtualMachineTemplatesClient.NewListByResourceGroupPager. -type VirtualMachineTemplatesClientListByResourceGroupResponse struct { - // List of VirtualMachineTemplates. - VirtualMachineTemplateListResult +// VirtualMachineInstancesClientDeleteCheckpointResponse contains the response from method VirtualMachineInstancesClient.BeginDeleteCheckpoint. +type VirtualMachineInstancesClientDeleteCheckpointResponse struct { + // placeholder for future response values } -// VirtualMachineTemplatesClientListBySubscriptionResponse contains the response from method VirtualMachineTemplatesClient.NewListBySubscriptionPager. -type VirtualMachineTemplatesClientListBySubscriptionResponse struct { - // List of VirtualMachineTemplates. - VirtualMachineTemplateListResult +// VirtualMachineInstancesClientDeleteResponse contains the response from method VirtualMachineInstancesClient.BeginDelete. +type VirtualMachineInstancesClientDeleteResponse struct { + // placeholder for future response values } -// VirtualMachineTemplatesClientUpdateResponse contains the response from method VirtualMachineTemplatesClient.BeginUpdate. -type VirtualMachineTemplatesClientUpdateResponse struct { - // The VirtualMachineTemplates resource definition. - VirtualMachineTemplate +// VirtualMachineInstancesClientGetResponse contains the response from method VirtualMachineInstancesClient.Get. +type VirtualMachineInstancesClientGetResponse struct { + // Define the virtualMachineInstance. + VirtualMachineInstance } -// VirtualMachinesClientCreateCheckpointResponse contains the response from method VirtualMachinesClient.BeginCreateCheckpoint. -type VirtualMachinesClientCreateCheckpointResponse struct { - // placeholder for future response values +// VirtualMachineInstancesClientListResponse contains the response from method VirtualMachineInstancesClient.NewListPager. +type VirtualMachineInstancesClientListResponse struct { + // The response of a VirtualMachineInstance list operation. + VirtualMachineInstanceListResult } -// VirtualMachinesClientCreateOrUpdateResponse contains the response from method VirtualMachinesClient.BeginCreateOrUpdate. -type VirtualMachinesClientCreateOrUpdateResponse struct { - // The VirtualMachines resource definition. - VirtualMachine +// VirtualMachineInstancesClientRestartResponse contains the response from method VirtualMachineInstancesClient.BeginRestart. +type VirtualMachineInstancesClientRestartResponse struct { + // placeholder for future response values } -// VirtualMachinesClientDeleteCheckpointResponse contains the response from method VirtualMachinesClient.BeginDeleteCheckpoint. -type VirtualMachinesClientDeleteCheckpointResponse struct { +// VirtualMachineInstancesClientRestoreCheckpointResponse contains the response from method VirtualMachineInstancesClient.BeginRestoreCheckpoint. +type VirtualMachineInstancesClientRestoreCheckpointResponse struct { // placeholder for future response values } -// VirtualMachinesClientDeleteResponse contains the response from method VirtualMachinesClient.BeginDelete. -type VirtualMachinesClientDeleteResponse struct { +// VirtualMachineInstancesClientStartResponse contains the response from method VirtualMachineInstancesClient.BeginStart. +type VirtualMachineInstancesClientStartResponse struct { // placeholder for future response values } -// VirtualMachinesClientGetResponse contains the response from method VirtualMachinesClient.Get. -type VirtualMachinesClientGetResponse struct { - // The VirtualMachines resource definition. - VirtualMachine +// VirtualMachineInstancesClientStopResponse contains the response from method VirtualMachineInstancesClient.BeginStop. +type VirtualMachineInstancesClientStopResponse struct { + // placeholder for future response values } -// VirtualMachinesClientListByResourceGroupResponse contains the response from method VirtualMachinesClient.NewListByResourceGroupPager. -type VirtualMachinesClientListByResourceGroupResponse struct { - // List of VirtualMachines. - VirtualMachineListResult +// VirtualMachineInstancesClientUpdateResponse contains the response from method VirtualMachineInstancesClient.BeginUpdate. +type VirtualMachineInstancesClientUpdateResponse struct { + // Define the virtualMachineInstance. + VirtualMachineInstance } -// VirtualMachinesClientListBySubscriptionResponse contains the response from method VirtualMachinesClient.NewListBySubscriptionPager. -type VirtualMachinesClientListBySubscriptionResponse struct { - // List of VirtualMachines. - VirtualMachineListResult +// VirtualMachineTemplatesClientCreateOrUpdateResponse contains the response from method VirtualMachineTemplatesClient.BeginCreateOrUpdate. +type VirtualMachineTemplatesClientCreateOrUpdateResponse struct { + // The VirtualMachineTemplates resource definition. + VirtualMachineTemplate } -// VirtualMachinesClientRestartResponse contains the response from method VirtualMachinesClient.BeginRestart. -type VirtualMachinesClientRestartResponse struct { +// VirtualMachineTemplatesClientDeleteResponse contains the response from method VirtualMachineTemplatesClient.BeginDelete. +type VirtualMachineTemplatesClientDeleteResponse struct { // placeholder for future response values } -// VirtualMachinesClientRestoreCheckpointResponse contains the response from method VirtualMachinesClient.BeginRestoreCheckpoint. -type VirtualMachinesClientRestoreCheckpointResponse struct { - // placeholder for future response values +// VirtualMachineTemplatesClientGetResponse contains the response from method VirtualMachineTemplatesClient.Get. +type VirtualMachineTemplatesClientGetResponse struct { + // The VirtualMachineTemplates resource definition. + VirtualMachineTemplate } -// VirtualMachinesClientStartResponse contains the response from method VirtualMachinesClient.BeginStart. -type VirtualMachinesClientStartResponse struct { - // placeholder for future response values +// VirtualMachineTemplatesClientListByResourceGroupResponse contains the response from method VirtualMachineTemplatesClient.NewListByResourceGroupPager. +type VirtualMachineTemplatesClientListByResourceGroupResponse struct { + // The response of a VirtualMachineTemplate list operation. + VirtualMachineTemplateListResult } -// VirtualMachinesClientStopResponse contains the response from method VirtualMachinesClient.BeginStop. -type VirtualMachinesClientStopResponse struct { - // placeholder for future response values +// VirtualMachineTemplatesClientListBySubscriptionResponse contains the response from method VirtualMachineTemplatesClient.NewListBySubscriptionPager. +type VirtualMachineTemplatesClientListBySubscriptionResponse struct { + // The response of a VirtualMachineTemplate list operation. + VirtualMachineTemplateListResult } -// VirtualMachinesClientUpdateResponse contains the response from method VirtualMachinesClient.BeginUpdate. -type VirtualMachinesClientUpdateResponse struct { - // The VirtualMachines resource definition. - VirtualMachine +// VirtualMachineTemplatesClientUpdateResponse contains the response from method VirtualMachineTemplatesClient.BeginUpdate. +type VirtualMachineTemplatesClientUpdateResponse struct { + // The VirtualMachineTemplates resource definition. + VirtualMachineTemplate } // VirtualNetworksClientCreateOrUpdateResponse contains the response from method VirtualNetworksClient.BeginCreateOrUpdate. @@ -226,13 +255,13 @@ type VirtualNetworksClientGetResponse struct { // VirtualNetworksClientListByResourceGroupResponse contains the response from method VirtualNetworksClient.NewListByResourceGroupPager. type VirtualNetworksClientListByResourceGroupResponse struct { - // List of VirtualNetworks. + // The response of a VirtualNetwork list operation. VirtualNetworkListResult } // VirtualNetworksClientListBySubscriptionResponse contains the response from method VirtualNetworksClient.NewListBySubscriptionPager. type VirtualNetworksClientListBySubscriptionResponse struct { - // List of VirtualNetworks. + // The response of a VirtualNetwork list operation. VirtualNetworkListResult } @@ -245,7 +274,7 @@ type VirtualNetworksClientUpdateResponse struct { // VmmServersClientCreateOrUpdateResponse contains the response from method VmmServersClient.BeginCreateOrUpdate. type VmmServersClientCreateOrUpdateResponse struct { // The VmmServers resource definition. - VMMServer + VmmServer } // VmmServersClientDeleteResponse contains the response from method VmmServersClient.BeginDelete. @@ -256,23 +285,23 @@ type VmmServersClientDeleteResponse struct { // VmmServersClientGetResponse contains the response from method VmmServersClient.Get. type VmmServersClientGetResponse struct { // The VmmServers resource definition. - VMMServer + VmmServer } // VmmServersClientListByResourceGroupResponse contains the response from method VmmServersClient.NewListByResourceGroupPager. type VmmServersClientListByResourceGroupResponse struct { - // List of VmmServers. - VMMServerListResult + // The response of a VmmServer list operation. + VmmServerListResult } // VmmServersClientListBySubscriptionResponse contains the response from method VmmServersClient.NewListBySubscriptionPager. type VmmServersClientListBySubscriptionResponse struct { - // List of VmmServers. - VMMServerListResult + // The response of a VmmServer list operation. + VmmServerListResult } // VmmServersClientUpdateResponse contains the response from method VmmServersClient.BeginUpdate. type VmmServersClientUpdateResponse struct { // The VmmServers resource definition. - VMMServer + VmmServer } diff --git a/sdk/resourcemanager/scvmm/armscvmm/time_rfc3339.go b/sdk/resourcemanager/scvmm/armscvmm/time_rfc3339.go index 5d7b1b36ac03..acbe2d31cf8f 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/time_rfc3339.go +++ b/sdk/resourcemanager/scvmm/armscvmm/time_rfc3339.go @@ -19,12 +19,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +44,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/scvmm/armscvmm/virtualmachineinstances_client.go b/sdk/resourcemanager/scvmm/armscvmm/virtualmachineinstances_client.go new file mode 100644 index 000000000000..0ad33f957eca --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/virtualmachineinstances_client.go @@ -0,0 +1,762 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armscvmm + +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" +) + +// 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, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &VirtualMachineInstancesClient{ + internal: cl, + } + return client, nil +} + +// BeginCreateCheckpoint - Creates a checkpoint in virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - body - The content of the action request +// - options - VirtualMachineInstancesClientBeginCreateCheckpointOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginCreateCheckpoint +// method. +func (client *VirtualMachineInstancesClient) BeginCreateCheckpoint(ctx context.Context, resourceURI string, body VirtualMachineCreateCheckpoint, options *VirtualMachineInstancesClientBeginCreateCheckpointOptions) (*runtime.Poller[VirtualMachineInstancesClientCreateCheckpointResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createCheckpoint(ctx, resourceURI, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineInstancesClientCreateCheckpointResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachineInstancesClientCreateCheckpointResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateCheckpoint - Creates a checkpoint in virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-01 +func (client *VirtualMachineInstancesClient) createCheckpoint(ctx context.Context, resourceURI string, body VirtualMachineCreateCheckpoint, options *VirtualMachineInstancesClientBeginCreateCheckpointOptions) (*http.Response, error) { + var err error + const operationName = "VirtualMachineInstancesClient.BeginCreateCheckpoint" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCheckpointCreateRequest(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.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCheckpointCreateRequest creates the CreateCheckpoint request. +func (client *VirtualMachineInstancesClient) createCheckpointCreateRequest(ctx context.Context, resourceURI string, body VirtualMachineCreateCheckpoint, options *VirtualMachineInstancesClientBeginCreateCheckpointOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ScVmm/virtualMachineInstances/default/createCheckpoint" + 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", "2024-06-01") + 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 +} + +// 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 2024-06-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - resource - Resource create parameters. +// - options - VirtualMachineInstancesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginCreateOrUpdate +// method. +func (client *VirtualMachineInstancesClient) BeginCreateOrUpdate(ctx context.Context, resourceURI string, resource VirtualMachineInstance, options *VirtualMachineInstancesClientBeginCreateOrUpdateOptions) (*runtime.Poller[VirtualMachineInstancesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceURI, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineInstancesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachineInstancesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// 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 2024-06-01 +func (client *VirtualMachineInstancesClient) createOrUpdate(ctx context.Context, resourceURI string, resource VirtualMachineInstance, options *VirtualMachineInstancesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "VirtualMachineInstancesClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceURI, resource, 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, resource VirtualMachineInstance, options *VirtualMachineInstancesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ScVmm/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", "2024-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); 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 2024-06-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - 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, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachineInstancesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - The operation to delete a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-01 +func (client *VirtualMachineInstancesClient) deleteOperation(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "VirtualMachineInstancesClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + 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.ScVmm/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", "2024-06-01") + if options != nil && options.DeleteFromHost != nil { + reqQP.Set("deleteFromHost", string(*options.DeleteFromHost)) + } + if options != nil && options.Force != nil { + reqQP.Set("force", string(*options.Force)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginDeleteCheckpoint - Deletes a checkpoint in virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - body - The content of the action request +// - options - VirtualMachineInstancesClientBeginDeleteCheckpointOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginDeleteCheckpoint +// method. +func (client *VirtualMachineInstancesClient) BeginDeleteCheckpoint(ctx context.Context, resourceURI string, body VirtualMachineDeleteCheckpoint, options *VirtualMachineInstancesClientBeginDeleteCheckpointOptions) (*runtime.Poller[VirtualMachineInstancesClientDeleteCheckpointResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteCheckpoint(ctx, resourceURI, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineInstancesClientDeleteCheckpointResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachineInstancesClientDeleteCheckpointResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// DeleteCheckpoint - Deletes a checkpoint in virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-01 +func (client *VirtualMachineInstancesClient) deleteCheckpoint(ctx context.Context, resourceURI string, body VirtualMachineDeleteCheckpoint, options *VirtualMachineInstancesClientBeginDeleteCheckpointOptions) (*http.Response, error) { + var err error + const operationName = "VirtualMachineInstancesClient.BeginDeleteCheckpoint" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCheckpointCreateRequest(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.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCheckpointCreateRequest creates the DeleteCheckpoint request. +func (client *VirtualMachineInstancesClient) deleteCheckpointCreateRequest(ctx context.Context, resourceURI string, body VirtualMachineDeleteCheckpoint, options *VirtualMachineInstancesClientBeginDeleteCheckpointOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ScVmm/virtualMachineInstances/default/deleteCheckpoint" + 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", "2024-06-01") + 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 +} + +// Get - Retrieves information about a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - 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 + const operationName = "VirtualMachineInstancesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + 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.ScVmm/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", "2024-06-01") + 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 2024-06-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - 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) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VirtualMachineInstancesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceURI, options) + }, nil) + if err != nil { + return VirtualMachineInstancesClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *VirtualMachineInstancesClient) listCreateRequest(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientListOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ScVmm/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", "2024-06-01") + 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.VirtualMachineInstanceListResult); 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 2024-06-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - 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, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachineInstancesClientRestartResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Restart - The operation to restart a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-01 +func (client *VirtualMachineInstancesClient) restart(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientBeginRestartOptions) (*http.Response, error) { + var err error + const operationName = "VirtualMachineInstancesClient.BeginRestart" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + 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.ScVmm/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", "2024-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginRestoreCheckpoint - Restores to a checkpoint in virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - body - The content of the action request +// - options - VirtualMachineInstancesClientBeginRestoreCheckpointOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginRestoreCheckpoint +// method. +func (client *VirtualMachineInstancesClient) BeginRestoreCheckpoint(ctx context.Context, resourceURI string, body VirtualMachineRestoreCheckpoint, options *VirtualMachineInstancesClientBeginRestoreCheckpointOptions) (*runtime.Poller[VirtualMachineInstancesClientRestoreCheckpointResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.restoreCheckpoint(ctx, resourceURI, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineInstancesClientRestoreCheckpointResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachineInstancesClientRestoreCheckpointResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// RestoreCheckpoint - Restores to a checkpoint in virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-01 +func (client *VirtualMachineInstancesClient) restoreCheckpoint(ctx context.Context, resourceURI string, body VirtualMachineRestoreCheckpoint, options *VirtualMachineInstancesClientBeginRestoreCheckpointOptions) (*http.Response, error) { + var err error + const operationName = "VirtualMachineInstancesClient.BeginRestoreCheckpoint" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.restoreCheckpointCreateRequest(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.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// restoreCheckpointCreateRequest creates the RestoreCheckpoint request. +func (client *VirtualMachineInstancesClient) restoreCheckpointCreateRequest(ctx context.Context, resourceURI string, body VirtualMachineRestoreCheckpoint, options *VirtualMachineInstancesClientBeginRestoreCheckpointOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ScVmm/virtualMachineInstances/default/restoreCheckpoint" + 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", "2024-06-01") + 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 +} + +// BeginStart - The operation to start a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - 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, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachineInstancesClientStartResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Start - The operation to start a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-01 +func (client *VirtualMachineInstancesClient) start(ctx context.Context, resourceURI string, options *VirtualMachineInstancesClientBeginStartOptions) (*http.Response, error) { + var err error + const operationName = "VirtualMachineInstancesClient.BeginStart" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + 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.ScVmm/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", "2024-06-01") + 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 2024-06-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - body - The content of the action request +// - options - VirtualMachineInstancesClientBeginStopOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginStop +// method. +func (client *VirtualMachineInstancesClient) BeginStop(ctx context.Context, resourceURI string, body StopVirtualMachineOptions, options *VirtualMachineInstancesClientBeginStopOptions) (*runtime.Poller[VirtualMachineInstancesClientStopResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.stop(ctx, resourceURI, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineInstancesClientStopResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachineInstancesClientStopResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// 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 2024-06-01 +func (client *VirtualMachineInstancesClient) stop(ctx context.Context, resourceURI string, body StopVirtualMachineOptions, options *VirtualMachineInstancesClientBeginStopOptions) (*http.Response, error) { + var err error + const operationName = "VirtualMachineInstancesClient.BeginStop" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.stopCreateRequest(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.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, body StopVirtualMachineOptions, options *VirtualMachineInstancesClientBeginStopOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ScVmm/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", "2024-06-01") + 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 +} + +// BeginUpdate - The operation to update a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - properties - The resource properties to be updated. +// - options - VirtualMachineInstancesClientBeginUpdateOptions contains the optional parameters for the VirtualMachineInstancesClient.BeginUpdate +// method. +func (client *VirtualMachineInstancesClient) BeginUpdate(ctx context.Context, resourceURI string, properties VirtualMachineInstanceUpdate, options *VirtualMachineInstancesClientBeginUpdateOptions) (*runtime.Poller[VirtualMachineInstancesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceURI, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineInstancesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachineInstancesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - The operation to update a virtual machine instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-01 +func (client *VirtualMachineInstancesClient) update(ctx context.Context, resourceURI string, properties VirtualMachineInstanceUpdate, options *VirtualMachineInstancesClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "VirtualMachineInstancesClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceURI, properties, 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, properties VirtualMachineInstanceUpdate, options *VirtualMachineInstancesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ScVmm/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", "2024-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/virtualmachines_client.go b/sdk/resourcemanager/scvmm/armscvmm/virtualmachines_client.go deleted file mode 100644 index 0e6bc51db604..000000000000 --- a/sdk/resourcemanager/scvmm/armscvmm/virtualmachines_client.go +++ /dev/null @@ -1,949 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armscvmm - -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" - "strconv" - "strings" -) - -// VirtualMachinesClient contains the methods for the VirtualMachines group. -// Don't use this type directly, use NewVirtualMachinesClient() instead. -type VirtualMachinesClient struct { - internal *arm.Client - subscriptionID string -} - -// NewVirtualMachinesClient creates a new instance of VirtualMachinesClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewVirtualMachinesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualMachinesClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &VirtualMachinesClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// BeginCreateCheckpoint - Creates a checkpoint in virtual machine. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - virtualMachineName - Name of the VirtualMachine. -// - options - VirtualMachinesClientBeginCreateCheckpointOptions contains the optional parameters for the VirtualMachinesClient.BeginCreateCheckpoint -// method. -func (client *VirtualMachinesClient) BeginCreateCheckpoint(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginCreateCheckpointOptions) (*runtime.Poller[VirtualMachinesClientCreateCheckpointResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.createCheckpoint(ctx, resourceGroupName, virtualMachineName, options) - if err != nil { - return nil, err - } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientCreateCheckpointResponse]{ - Tracer: client.internal.Tracer(), - }) - return poller, err - } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachinesClientCreateCheckpointResponse]{ - Tracer: client.internal.Tracer(), - }) - } -} - -// CreateCheckpoint - Creates a checkpoint in virtual machine. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -func (client *VirtualMachinesClient) createCheckpoint(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginCreateCheckpointOptions) (*http.Response, error) { - var err error - const operationName = "VirtualMachinesClient.BeginCreateCheckpoint" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.createCheckpointCreateRequest(ctx, resourceGroupName, virtualMachineName, 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 -} - -// createCheckpointCreateRequest creates the CreateCheckpoint request. -func (client *VirtualMachinesClient) createCheckpointCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginCreateCheckpointOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/createCheckpoint" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - 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", "2020-06-05-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 -} - -// BeginCreateOrUpdate - Creates Or Updates virtual machines deployed on scvmm fabric. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - virtualMachineName - Name of the VirtualMachine. -// - body - Request payload. -// - options - VirtualMachinesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginCreateOrUpdate -// method. -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.createOrUpdate(ctx, resourceGroupName, virtualMachineName, body, options) - if err != nil { - return nil, err - } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientCreateOrUpdateResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - Tracer: client.internal.Tracer(), - }) - return poller, err - } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachinesClientCreateOrUpdateResponse]{ - Tracer: client.internal.Tracer(), - }) - } -} - -// CreateOrUpdate - Creates Or Updates virtual machines deployed on scvmm fabric. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -func (client *VirtualMachinesClient) createOrUpdate(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachine, options *VirtualMachinesClientBeginCreateOrUpdateOptions) (*http.Response, error) { - var err error - const operationName = "VirtualMachinesClient.BeginCreateOrUpdate" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, virtualMachineName, 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 *VirtualMachinesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachine, options *VirtualMachinesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}" - 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.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-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 - Deletes a VirtualMachine deployed on ScVmm fabric. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - virtualMachineName - Name of the VirtualMachine. -// - options - VirtualMachinesClientBeginDeleteOptions contains the optional parameters for the VirtualMachinesClient.BeginDelete -// method. -func (client *VirtualMachinesClient) BeginDelete(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteOptions) (*runtime.Poller[VirtualMachinesClientDeleteResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.deleteOperation(ctx, resourceGroupName, virtualMachineName, options) - if err != nil { - return nil, err - } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientDeleteResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - Tracer: client.internal.Tracer(), - }) - return poller, err - } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachinesClientDeleteResponse]{ - Tracer: client.internal.Tracer(), - }) - } -} - -// Delete - Deletes a VirtualMachine deployed on ScVmm fabric. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -func (client *VirtualMachinesClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteOptions) (*http.Response, error) { - var err error - const operationName = "VirtualMachinesClient.BeginDelete" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.deleteCreateRequest(ctx, resourceGroupName, virtualMachineName, 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, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return nil, err - } - return httpResp, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *VirtualMachinesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}" - 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.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") - if options != nil && options.Retain != nil { - reqQP.Set("retain", strconv.FormatBool(*options.Retain)) - } - 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 -} - -// BeginDeleteCheckpoint - Deletes a checkpoint in virtual machine. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - virtualMachineName - Name of the VirtualMachine. -// - options - VirtualMachinesClientBeginDeleteCheckpointOptions contains the optional parameters for the VirtualMachinesClient.BeginDeleteCheckpoint -// method. -func (client *VirtualMachinesClient) BeginDeleteCheckpoint(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteCheckpointOptions) (*runtime.Poller[VirtualMachinesClientDeleteCheckpointResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.deleteCheckpoint(ctx, resourceGroupName, virtualMachineName, options) - if err != nil { - return nil, err - } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientDeleteCheckpointResponse]{ - Tracer: client.internal.Tracer(), - }) - return poller, err - } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachinesClientDeleteCheckpointResponse]{ - Tracer: client.internal.Tracer(), - }) - } -} - -// DeleteCheckpoint - Deletes a checkpoint in virtual machine. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -func (client *VirtualMachinesClient) deleteCheckpoint(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteCheckpointOptions) (*http.Response, error) { - var err error - const operationName = "VirtualMachinesClient.BeginDeleteCheckpoint" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.deleteCheckpointCreateRequest(ctx, resourceGroupName, virtualMachineName, 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 -} - -// deleteCheckpointCreateRequest creates the DeleteCheckpoint request. -func (client *VirtualMachinesClient) deleteCheckpointCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteCheckpointOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/deleteCheckpoint" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - 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", "2020-06-05-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 -} - -// Get - Implements VirtualMachine GET method. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - virtualMachineName - Name of the VirtualMachine. -// - 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 - const operationName = "VirtualMachinesClient.Get" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, resourceGroupName, virtualMachineName, options) - if err != nil { - return VirtualMachinesClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VirtualMachinesClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return VirtualMachinesClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *VirtualMachinesClient) getCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}" - 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.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *VirtualMachinesClient) getHandleResponse(resp *http.Response) (VirtualMachinesClientGetResponse, error) { - result := VirtualMachinesClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachine); err != nil { - return VirtualMachinesClientGetResponse{}, err - } - return result, nil -} - -// NewListByResourceGroupPager - List of VirtualMachines in a resource group. -// -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - options - VirtualMachinesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachinesClient.NewListByResourceGroupPager -// method. -func (client *VirtualMachinesClient) NewListByResourceGroupPager(resourceGroupName string, options *VirtualMachinesClientListByResourceGroupOptions) *runtime.Pager[VirtualMachinesClientListByResourceGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[VirtualMachinesClientListByResourceGroupResponse]{ - More: func(page VirtualMachinesClientListByResourceGroupResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *VirtualMachinesClientListByResourceGroupResponse) (VirtualMachinesClientListByResourceGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VirtualMachinesClient.NewListByResourceGroupPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - }, nil) - if err != nil { - return VirtualMachinesClientListByResourceGroupResponse{}, err - } - return client.listByResourceGroupHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// 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.ScVmm/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", "2020-06-05-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{} - if err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachineListResult); err != nil { - return VirtualMachinesClientListByResourceGroupResponse{}, err - } - return result, nil -} - -// NewListBySubscriptionPager - List of VirtualMachines in a subscription. -// -// Generated from API version 2020-06-05-preview -// - options - VirtualMachinesClientListBySubscriptionOptions contains the optional parameters for the VirtualMachinesClient.NewListBySubscriptionPager -// method. -func (client *VirtualMachinesClient) NewListBySubscriptionPager(options *VirtualMachinesClientListBySubscriptionOptions) *runtime.Pager[VirtualMachinesClientListBySubscriptionResponse] { - return runtime.NewPager(runtime.PagingHandler[VirtualMachinesClientListBySubscriptionResponse]{ - More: func(page VirtualMachinesClientListBySubscriptionResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *VirtualMachinesClientListBySubscriptionResponse) (VirtualMachinesClientListBySubscriptionResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VirtualMachinesClient.NewListBySubscriptionPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listBySubscriptionCreateRequest(ctx, options) - }, nil) - if err != nil { - return VirtualMachinesClientListBySubscriptionResponse{}, err - } - return client.listBySubscriptionHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listBySubscriptionCreateRequest creates the ListBySubscription request. -func (client *VirtualMachinesClient) listBySubscriptionCreateRequest(ctx context.Context, options *VirtualMachinesClientListBySubscriptionOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ScVmm/virtualMachines" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - 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", "2020-06-05-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listBySubscriptionHandleResponse handles the ListBySubscription response. -func (client *VirtualMachinesClient) listBySubscriptionHandleResponse(resp *http.Response) (VirtualMachinesClientListBySubscriptionResponse, error) { - result := VirtualMachinesClientListBySubscriptionResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachineListResult); err != nil { - return VirtualMachinesClientListBySubscriptionResponse{}, err - } - return result, nil -} - -// BeginRestart - Restart virtual machine. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - virtualMachineName - Name of the VirtualMachine. -// - options - VirtualMachinesClientBeginRestartOptions contains the optional parameters for the VirtualMachinesClient.BeginRestart -// method. -func (client *VirtualMachinesClient) BeginRestart(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginRestartOptions) (*runtime.Poller[VirtualMachinesClientRestartResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.restart(ctx, resourceGroupName, virtualMachineName, options) - if err != nil { - return nil, err - } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientRestartResponse]{ - Tracer: client.internal.Tracer(), - }) - return poller, err - } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachinesClientRestartResponse]{ - Tracer: client.internal.Tracer(), - }) - } -} - -// Restart - Restart virtual machine. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -func (client *VirtualMachinesClient) restart(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginRestartOptions) (*http.Response, error) { - var err error - const operationName = "VirtualMachinesClient.BeginRestart" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.restartCreateRequest(ctx, resourceGroupName, virtualMachineName, 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 -} - -// restartCreateRequest creates the Restart request. -func (client *VirtualMachinesClient) restartCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginRestartOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/restart" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - 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", "2020-06-05-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// BeginRestoreCheckpoint - Restores to a checkpoint in virtual machine. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - virtualMachineName - Name of the VirtualMachine. -// - options - VirtualMachinesClientBeginRestoreCheckpointOptions contains the optional parameters for the VirtualMachinesClient.BeginRestoreCheckpoint -// method. -func (client *VirtualMachinesClient) BeginRestoreCheckpoint(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginRestoreCheckpointOptions) (*runtime.Poller[VirtualMachinesClientRestoreCheckpointResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.restoreCheckpoint(ctx, resourceGroupName, virtualMachineName, options) - if err != nil { - return nil, err - } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientRestoreCheckpointResponse]{ - Tracer: client.internal.Tracer(), - }) - return poller, err - } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachinesClientRestoreCheckpointResponse]{ - Tracer: client.internal.Tracer(), - }) - } -} - -// RestoreCheckpoint - Restores to a checkpoint in virtual machine. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -func (client *VirtualMachinesClient) restoreCheckpoint(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginRestoreCheckpointOptions) (*http.Response, error) { - var err error - const operationName = "VirtualMachinesClient.BeginRestoreCheckpoint" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.restoreCheckpointCreateRequest(ctx, resourceGroupName, virtualMachineName, 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 -} - -// restoreCheckpointCreateRequest creates the RestoreCheckpoint request. -func (client *VirtualMachinesClient) restoreCheckpointCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginRestoreCheckpointOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/restoreCheckpoint" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - 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", "2020-06-05-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 -} - -// BeginStart - Start virtual machine. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - virtualMachineName - Name of the VirtualMachine. -// - options - VirtualMachinesClientBeginStartOptions contains the optional parameters for the VirtualMachinesClient.BeginStart -// method. -func (client *VirtualMachinesClient) BeginStart(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStartOptions) (*runtime.Poller[VirtualMachinesClientStartResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.start(ctx, resourceGroupName, virtualMachineName, options) - if err != nil { - return nil, err - } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientStartResponse]{ - Tracer: client.internal.Tracer(), - }) - return poller, err - } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachinesClientStartResponse]{ - Tracer: client.internal.Tracer(), - }) - } -} - -// Start - Start virtual machine. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -func (client *VirtualMachinesClient) start(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStartOptions) (*http.Response, error) { - var err error - const operationName = "VirtualMachinesClient.BeginStart" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.startCreateRequest(ctx, resourceGroupName, virtualMachineName, 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 -} - -// startCreateRequest creates the Start request. -func (client *VirtualMachinesClient) startCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStartOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/start" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - 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", "2020-06-05-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// BeginStop - Stop virtual machine. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - virtualMachineName - Name of the VirtualMachine. -// - options - VirtualMachinesClientBeginStopOptions contains the optional parameters for the VirtualMachinesClient.BeginStop -// method. -func (client *VirtualMachinesClient) BeginStop(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStopOptions) (*runtime.Poller[VirtualMachinesClientStopResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.stop(ctx, resourceGroupName, virtualMachineName, options) - if err != nil { - return nil, err - } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientStopResponse]{ - Tracer: client.internal.Tracer(), - }) - return poller, err - } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachinesClientStopResponse]{ - Tracer: client.internal.Tracer(), - }) - } -} - -// Stop - Stop virtual machine. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -func (client *VirtualMachinesClient) stop(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStopOptions) (*http.Response, error) { - var err error - const operationName = "VirtualMachinesClient.BeginStop" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.stopCreateRequest(ctx, resourceGroupName, virtualMachineName, 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 -} - -// stopCreateRequest creates the Stop request. -func (client *VirtualMachinesClient) stopCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginStopOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}/stop" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - 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", "2020-06-05-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 - Updates the VirtualMachines resource. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - virtualMachineName - Name of the VirtualMachine. -// - body - VirtualMachines patch payload. -// - options - VirtualMachinesClientBeginUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginUpdate -// method. -func (client *VirtualMachinesClient) BeginUpdate(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachineUpdate, options *VirtualMachinesClientBeginUpdateOptions) (*runtime.Poller[VirtualMachinesClientUpdateResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.update(ctx, resourceGroupName, virtualMachineName, body, options) - if err != nil { - return nil, err - } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientUpdateResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - Tracer: client.internal.Tracer(), - }) - return poller, err - } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachinesClientUpdateResponse]{ - Tracer: client.internal.Tracer(), - }) - } -} - -// Update - Updates the VirtualMachines resource. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-06-05-preview -func (client *VirtualMachinesClient) update(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachineUpdate, options *VirtualMachinesClientBeginUpdateOptions) (*http.Response, error) { - var err error - const operationName = "VirtualMachinesClient.BeginUpdate" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, resourceGroupName, virtualMachineName, 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, http.StatusAccepted) { - err = runtime.NewResponseError(httpResp) - return nil, err - } - return httpResp, nil -} - -// updateCreateRequest creates the Update request. -func (client *VirtualMachinesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, body VirtualMachineUpdate, options *VirtualMachinesClientBeginUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachines/{virtualMachineName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - 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.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-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/scvmm/armscvmm/virtualmachines_client_example_test.go b/sdk/resourcemanager/scvmm/armscvmm/virtualmachines_client_example_test.go deleted file mode 100644 index 9406543b2f51..000000000000 --- a/sdk/resourcemanager/scvmm/armscvmm/virtualmachines_client_example_test.go +++ /dev/null @@ -1,520 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// 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 armscvmm_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/scvmm/armscvmm" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-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 := armscvmm.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 = armscvmm.VirtualMachine{ - // Name: to.Ptr("DemoVM"), - // Type: to.Ptr("Microsoft.SCVMM/VirtualMachines"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachines/DemoVM"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VirtualMachineProperties{ - // CloudID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/Clouds/HRCloud"), - // HardwareProfile: &armscvmm.HardwareProfile{ - // CPUCount: to.Ptr[int32](4), - // MemoryMB: to.Ptr[int32](4096), - // }, - // OSProfile: &armscvmm.OsProfile{ - // ComputerName: to.Ptr("DemoVM"), - // OSType: to.Ptr(armscvmm.OsTypeWindows), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // TemplateID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachineTemplates/HRVirtualMachineTemplate"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/CreateVirtualMachine.json -func ExampleVirtualMachinesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachinesClient().BeginCreateOrUpdate(ctx, "testrg", "DemoVM", armscvmm.VirtualMachine{ - ExtendedLocation: &armscvmm.ExtendedLocation{ - Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - Type: to.Ptr("customLocation"), - }, - Location: to.Ptr("East US"), - Properties: &armscvmm.VirtualMachineProperties{ - CloudID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/Clouds/HRCloud"), - HardwareProfile: &armscvmm.HardwareProfile{ - CPUCount: to.Ptr[int32](4), - MemoryMB: to.Ptr[int32](4096), - }, - TemplateID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachineTemplates/HRVirtualMachineTemplate"), - VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - }, - }, 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 = armscvmm.VirtualMachine{ - // Name: to.Ptr("DemoVM"), - // Type: to.Ptr("Microsoft.SCVMM/VirtualMachines"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachines/DemoVM"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VirtualMachineProperties{ - // CloudID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/Clouds/HRCloud"), - // HardwareProfile: &armscvmm.HardwareProfile{ - // CPUCount: to.Ptr[int32](4), - // MemoryMB: to.Ptr[int32](4096), - // }, - // OSProfile: &armscvmm.OsProfile{ - // ComputerName: to.Ptr("DemoVM"), - // OSType: to.Ptr(armscvmm.OsTypeWindows), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // TemplateID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachineTemplates/HRVirtualMachineTemplate"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-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 := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachinesClient().BeginDelete(ctx, "testrg", "DemoVM", &armscvmm.VirtualMachinesClientBeginDeleteOptions{Retain: nil, - 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-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 := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachinesClient().BeginUpdate(ctx, "testrg", "DemoVM", armscvmm.VirtualMachineUpdate{ - Properties: &armscvmm.VirtualMachineUpdateProperties{ - HardwareProfile: &armscvmm.HardwareProfileUpdate{ - CPUCount: to.Ptr[int32](4), - MemoryMB: to.Ptr[int32](4096), - }, - NetworkProfile: &armscvmm.NetworkProfileUpdate{ - NetworkInterfaces: []*armscvmm.NetworkInterfacesUpdate{ - { - Name: to.Ptr("test"), - IPv4AddressType: to.Ptr(armscvmm.AllocationMethodDynamic), - IPv6AddressType: to.Ptr(armscvmm.AllocationMethodDynamic), - MacAddressType: to.Ptr(armscvmm.AllocationMethodStatic), - }}, - }, - StorageProfile: &armscvmm.StorageProfileUpdate{ - Disks: []*armscvmm.VirtualDiskUpdate{ - { - Name: to.Ptr("test"), - DiskSizeGB: to.Ptr[int32](10), - }}, - }, - }, - 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 = armscvmm.VirtualMachine{ - // Name: to.Ptr("DemoVM"), - // Type: to.Ptr("Microsoft.SCVMM/VirtualMachines"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachines/DemoVM"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VirtualMachineProperties{ - // CloudID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/Clouds/HRCloud"), - // Generation: to.Ptr[int32](0), - // HardwareProfile: &armscvmm.HardwareProfile{ - // CPUCount: to.Ptr[int32](4), - // DynamicMemoryEnabled: to.Ptr(armscvmm.DynamicMemoryEnabledFalse), - // DynamicMemoryMaxMB: to.Ptr[int32](0), - // DynamicMemoryMinMB: to.Ptr[int32](0), - // IsHighlyAvailable: to.Ptr("string"), - // MemoryMB: to.Ptr[int32](4096), - // }, - // NetworkProfile: &armscvmm.NetworkProfile{ - // NetworkInterfaces: []*armscvmm.NetworkInterfaces{ - // { - // Name: to.Ptr("test"), - // DisplayName: to.Ptr("string"), - // IPv4AddressType: to.Ptr(armscvmm.AllocationMethodDynamic), - // IPv4Addresses: []*string{ - // to.Ptr("string")}, - // IPv6AddressType: to.Ptr(armscvmm.AllocationMethodDynamic), - // IPv6Addresses: []*string{ - // to.Ptr("string")}, - // MacAddress: to.Ptr("string"), - // MacAddressType: to.Ptr(armscvmm.AllocationMethodStatic), - // NetworkName: to.Ptr("string"), - // NicID: to.Ptr("string"), - // VirtualNetworkID: to.Ptr("string"), - // }}, - // }, - // OSProfile: &armscvmm.OsProfile{ - // ComputerName: to.Ptr("DemoVM"), - // OSName: to.Ptr("string"), - // OSType: to.Ptr(armscvmm.OsTypeWindows), - // }, - // PowerState: to.Ptr("string"), - // ProvisioningState: to.Ptr("Succeeded"), - // StorageProfile: &armscvmm.StorageProfile{ - // Disks: []*armscvmm.VirtualDisk{ - // { - // Name: to.Ptr("test"), - // Bus: to.Ptr[int32](0), - // BusType: to.Ptr("string"), - // CreateDiffDisk: to.Ptr(armscvmm.CreateDiffDiskFalse), - // DiskID: to.Ptr("string"), - // DiskSizeGB: to.Ptr[int32](10), - // DisplayName: to.Ptr("string"), - // Lun: to.Ptr[int32](0), - // MaxDiskSizeGB: to.Ptr[int32](10), - // StorageQoSPolicy: &armscvmm.StorageQoSPolicyDetails{ - // Name: to.Ptr("string"), - // ID: to.Ptr("string"), - // }, - // TemplateDiskID: to.Ptr("string"), - // VhdFormatType: to.Ptr("string"), - // VhdType: to.Ptr("string"), - // VolumeType: to.Ptr("string"), - // }}, - // }, - // TemplateID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachineTemplates/HRVirtualMachineTemplate"), - // UUID: to.Ptr("string"), - // VMName: to.Ptr("string"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-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 := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachinesClient().BeginStop(ctx, "testrg", "DemoVM", &armscvmm.VirtualMachinesClientBeginStopOptions{Body: &armscvmm.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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-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 := armscvmm.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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-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 := armscvmm.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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/CreateCheckpointVirtualMachine.json -func ExampleVirtualMachinesClient_BeginCreateCheckpoint() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachinesClient().BeginCreateCheckpoint(ctx, "testrg", "DemoVM", &armscvmm.VirtualMachinesClientBeginCreateCheckpointOptions{Body: &armscvmm.VirtualMachineCreateCheckpoint{ - Name: to.Ptr("Demo Checkpoint name"), - Description: to.Ptr("Demo Checkpoint description"), - }, - }) - 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/DeleteCheckpointVirtualMachine.json -func ExampleVirtualMachinesClient_BeginDeleteCheckpoint() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachinesClient().BeginDeleteCheckpoint(ctx, "testrg", "DemoVM", &armscvmm.VirtualMachinesClientBeginDeleteCheckpointOptions{Body: &armscvmm.VirtualMachineDeleteCheckpoint{ - ID: to.Ptr("Demo CheckpointID"), - }, - }) - 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/RestoreCheckpointVirtualMachine.json -func ExampleVirtualMachinesClient_BeginRestoreCheckpoint() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachinesClient().BeginRestoreCheckpoint(ctx, "testrg", "DemoVM", &armscvmm.VirtualMachinesClientBeginRestoreCheckpointOptions{Body: &armscvmm.VirtualMachineRestoreCheckpoint{ - ID: to.Ptr("Demo CheckpointID"), - }, - }) - 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-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 := armscvmm.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.VirtualMachineListResult = armscvmm.VirtualMachineListResult{ - // Value: []*armscvmm.VirtualMachine{ - // { - // Name: to.Ptr("DemoVM"), - // Type: to.Ptr("Microsoft.SCVMM/VirtualMachines"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachines/DemoVM"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VirtualMachineProperties{ - // CloudID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/Clouds/HRCloud"), - // HardwareProfile: &armscvmm.HardwareProfile{ - // CPUCount: to.Ptr[int32](4), - // MemoryMB: to.Ptr[int32](4096), - // }, - // OSProfile: &armscvmm.OsProfile{ - // ComputerName: to.Ptr("DemoVM"), - // OSType: to.Ptr(armscvmm.OsTypeWindows), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // TemplateID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachineTemplates/HRVirtualMachineTemplate"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListVirtualMachinesBySubscription.json -func ExampleVirtualMachinesClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVirtualMachinesClient().NewListBySubscriptionPager(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.VirtualMachineListResult = armscvmm.VirtualMachineListResult{ - // Value: []*armscvmm.VirtualMachine{ - // { - // Name: to.Ptr("DemoVM"), - // Type: to.Ptr("Microsoft.SCVMM/VirtualMachines"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachines/DemoVM"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VirtualMachineProperties{ - // CloudID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/Clouds/HRCloud"), - // HardwareProfile: &armscvmm.HardwareProfile{ - // CPUCount: to.Ptr[int32](4), - // MemoryMB: to.Ptr[int32](4096), - // }, - // OSProfile: &armscvmm.OsProfile{ - // ComputerName: to.Ptr("DemoVM"), - // OSType: to.Ptr(armscvmm.OsTypeWindows), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // TemplateID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachineTemplates/HRVirtualMachineTemplate"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/scvmm/armscvmm/virtualmachinetemplates_client.go b/sdk/resourcemanager/scvmm/armscvmm/virtualmachinetemplates_client.go index 213c59b55d22..30b8ef90956b 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/virtualmachinetemplates_client.go +++ b/sdk/resourcemanager/scvmm/armscvmm/virtualmachinetemplates_client.go @@ -17,7 +17,6 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" - "strconv" "strings" ) @@ -29,7 +28,7 @@ type VirtualMachineTemplatesClient struct { } // NewVirtualMachineTemplatesClient creates a new instance of VirtualMachineTemplatesClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewVirtualMachineTemplatesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualMachineTemplatesClient, error) { @@ -47,15 +46,15 @@ func NewVirtualMachineTemplatesClient(subscriptionID string, credential azcore.T // BeginCreateOrUpdate - Onboards the ScVmm VM Template as an Azure VM Template resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - virtualMachineTemplateName - Name of the VirtualMachineTemplate. -// - body - Request payload. +// - resource - Resource create parameters. // - options - VirtualMachineTemplatesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginCreateOrUpdate // method. -func (client *VirtualMachineTemplatesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body VirtualMachineTemplate, options *VirtualMachineTemplatesClientBeginCreateOrUpdateOptions) (*runtime.Poller[VirtualMachineTemplatesClientCreateOrUpdateResponse], error) { +func (client *VirtualMachineTemplatesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, resource VirtualMachineTemplate, options *VirtualMachineTemplatesClientBeginCreateOrUpdateOptions) (*runtime.Poller[VirtualMachineTemplatesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.createOrUpdate(ctx, resourceGroupName, virtualMachineTemplateName, body, options) + resp, err := client.createOrUpdate(ctx, resourceGroupName, virtualMachineTemplateName, resource, options) if err != nil { return nil, err } @@ -74,14 +73,14 @@ func (client *VirtualMachineTemplatesClient) BeginCreateOrUpdate(ctx context.Con // CreateOrUpdate - Onboards the ScVmm VM Template as an Azure VM Template resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -func (client *VirtualMachineTemplatesClient) createOrUpdate(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body VirtualMachineTemplate, options *VirtualMachineTemplatesClientBeginCreateOrUpdateOptions) (*http.Response, error) { +// Generated from API version 2024-06-01 +func (client *VirtualMachineTemplatesClient) createOrUpdate(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, resource VirtualMachineTemplate, options *VirtualMachineTemplatesClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "VirtualMachineTemplatesClient.BeginCreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, virtualMachineTemplateName, body, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, virtualMachineTemplateName, resource, options) if err != nil { return nil, err } @@ -97,7 +96,7 @@ func (client *VirtualMachineTemplatesClient) createOrUpdate(ctx context.Context, } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *VirtualMachineTemplatesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body VirtualMachineTemplate, options *VirtualMachineTemplatesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *VirtualMachineTemplatesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, resource VirtualMachineTemplate, options *VirtualMachineTemplatesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -116,10 +115,10 @@ func (client *VirtualMachineTemplatesClient) createOrUpdateCreateRequest(ctx con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, body); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil @@ -128,8 +127,8 @@ func (client *VirtualMachineTemplatesClient) createOrUpdateCreateRequest(ctx con // BeginDelete - Deregisters the ScVmm VM Template from Azure. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - virtualMachineTemplateName - Name of the VirtualMachineTemplate. // - options - VirtualMachineTemplatesClientBeginDeleteOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginDelete // method. @@ -154,7 +153,7 @@ func (client *VirtualMachineTemplatesClient) BeginDelete(ctx context.Context, re // Delete - Deregisters the ScVmm VM Template from Azure. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview +// Generated from API version 2024-06-01 func (client *VirtualMachineTemplatesClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, options *VirtualMachineTemplatesClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "VirtualMachineTemplatesClient.BeginDelete" @@ -169,7 +168,7 @@ func (client *VirtualMachineTemplatesClient) deleteOperation(ctx context.Context if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -196,9 +195,9 @@ func (client *VirtualMachineTemplatesClient) deleteCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") if options != nil && options.Force != nil { - reqQP.Set("force", strconv.FormatBool(*options.Force)) + reqQP.Set("force", string(*options.Force)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} @@ -208,8 +207,8 @@ func (client *VirtualMachineTemplatesClient) deleteCreateRequest(ctx context.Con // Get - Implements VirtualMachineTemplate GET method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - virtualMachineTemplateName - Name of the VirtualMachineTemplate. // - options - VirtualMachineTemplatesClientGetOptions contains the optional parameters for the VirtualMachineTemplatesClient.Get // method. @@ -255,7 +254,7 @@ func (client *VirtualMachineTemplatesClient) getCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -272,8 +271,8 @@ func (client *VirtualMachineTemplatesClient) getHandleResponse(resp *http.Respon // NewListByResourceGroupPager - List of VirtualMachineTemplates in a resource group. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - VirtualMachineTemplatesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachineTemplatesClient.NewListByResourceGroupPager // method. func (client *VirtualMachineTemplatesClient) NewListByResourceGroupPager(resourceGroupName string, options *VirtualMachineTemplatesClientListByResourceGroupOptions) *runtime.Pager[VirtualMachineTemplatesClientListByResourceGroupResponse] { @@ -315,7 +314,7 @@ func (client *VirtualMachineTemplatesClient) listByResourceGroupCreateRequest(ct return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -332,7 +331,7 @@ func (client *VirtualMachineTemplatesClient) listByResourceGroupHandleResponse(r // NewListBySubscriptionPager - List of VirtualMachineTemplates in a subscription. // -// Generated from API version 2020-06-05-preview +// Generated from API version 2024-06-01 // - options - VirtualMachineTemplatesClientListBySubscriptionOptions contains the optional parameters for the VirtualMachineTemplatesClient.NewListBySubscriptionPager // method. func (client *VirtualMachineTemplatesClient) NewListBySubscriptionPager(options *VirtualMachineTemplatesClientListBySubscriptionOptions) *runtime.Pager[VirtualMachineTemplatesClientListBySubscriptionResponse] { @@ -370,7 +369,7 @@ func (client *VirtualMachineTemplatesClient) listBySubscriptionCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -388,15 +387,15 @@ func (client *VirtualMachineTemplatesClient) listBySubscriptionHandleResponse(re // BeginUpdate - Updates the VirtualMachineTemplate resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - virtualMachineTemplateName - Name of the VirtualMachineTemplate. -// - body - VirtualMachineTemplates patch details. +// - properties - The resource properties to be updated. // - options - VirtualMachineTemplatesClientBeginUpdateOptions contains the optional parameters for the VirtualMachineTemplatesClient.BeginUpdate // method. -func (client *VirtualMachineTemplatesClient) BeginUpdate(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body ResourcePatch, options *VirtualMachineTemplatesClientBeginUpdateOptions) (*runtime.Poller[VirtualMachineTemplatesClientUpdateResponse], error) { +func (client *VirtualMachineTemplatesClient) BeginUpdate(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, properties VirtualMachineTemplateTagsUpdate, options *VirtualMachineTemplatesClientBeginUpdateOptions) (*runtime.Poller[VirtualMachineTemplatesClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.update(ctx, resourceGroupName, virtualMachineTemplateName, body, options) + resp, err := client.update(ctx, resourceGroupName, virtualMachineTemplateName, properties, options) if err != nil { return nil, err } @@ -415,14 +414,14 @@ func (client *VirtualMachineTemplatesClient) BeginUpdate(ctx context.Context, re // Update - Updates the VirtualMachineTemplate resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -func (client *VirtualMachineTemplatesClient) update(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body ResourcePatch, options *VirtualMachineTemplatesClientBeginUpdateOptions) (*http.Response, error) { +// Generated from API version 2024-06-01 +func (client *VirtualMachineTemplatesClient) update(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, properties VirtualMachineTemplateTagsUpdate, options *VirtualMachineTemplatesClientBeginUpdateOptions) (*http.Response, error) { var err error const operationName = "VirtualMachineTemplatesClient.BeginUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, resourceGroupName, virtualMachineTemplateName, body, options) + req, err := client.updateCreateRequest(ctx, resourceGroupName, virtualMachineTemplateName, properties, options) if err != nil { return nil, err } @@ -430,7 +429,7 @@ func (client *VirtualMachineTemplatesClient) update(ctx context.Context, resourc if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -438,16 +437,16 @@ func (client *VirtualMachineTemplatesClient) update(ctx context.Context, resourc } // updateCreateRequest creates the Update request. -func (client *VirtualMachineTemplatesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, body ResourcePatch, options *VirtualMachineTemplatesClientBeginUpdateOptions) (*policy.Request, error) { +func (client *VirtualMachineTemplatesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineTemplateName string, properties VirtualMachineTemplateTagsUpdate, options *VirtualMachineTemplatesClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualMachineTemplates/{virtualMachineTemplateName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 virtualMachineTemplateName == "" { return nil, errors.New("parameter virtualMachineTemplateName cannot be empty") } @@ -457,10 +456,10 @@ func (client *VirtualMachineTemplatesClient) updateCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, body); err != nil { + if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } return req, nil diff --git a/sdk/resourcemanager/scvmm/armscvmm/virtualmachinetemplates_client_example_test.go b/sdk/resourcemanager/scvmm/armscvmm/virtualmachinetemplates_client_example_test.go deleted file mode 100644 index ac0552b5c5c6..000000000000 --- a/sdk/resourcemanager/scvmm/armscvmm/virtualmachinetemplates_client_example_test.go +++ /dev/null @@ -1,258 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// 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 armscvmm_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/scvmm/armscvmm" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-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 := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVirtualMachineTemplatesClient().Get(ctx, "testrg", "HRVirtualMachineTemplate", 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 = armscvmm.VirtualMachineTemplate{ - // Name: to.Ptr("HRVirtualMachineTemplate"), - // Type: to.Ptr("Microsoft.SCVMM/VirtualMachineTemplates"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachineTemplates/HRVirtualMachineTemplate"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VirtualMachineTemplateProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/CreateVirtualMachineTemplate.json -func ExampleVirtualMachineTemplatesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachineTemplatesClient().BeginCreateOrUpdate(ctx, "testrg", "HRVirtualMachineTemplate", armscvmm.VirtualMachineTemplate{ - ExtendedLocation: &armscvmm.ExtendedLocation{ - Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - Type: to.Ptr("customLocation"), - }, - Location: to.Ptr("East US"), - Properties: &armscvmm.VirtualMachineTemplateProperties{ - UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - }, - }, 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 = armscvmm.VirtualMachineTemplate{ - // Name: to.Ptr("HRVirtualMachineTemplate"), - // Type: to.Ptr("Microsoft.SCVMM/VirtualMachineTemplates"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachineTemplates/HRVirtualMachineTemplate"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VirtualMachineTemplateProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-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 := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachineTemplatesClient().BeginDelete(ctx, "testrg", "HRVirtualMachineTemplate", &armscvmm.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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/UpdateVirtualMachineTemplate.json -func ExampleVirtualMachineTemplatesClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualMachineTemplatesClient().BeginUpdate(ctx, "testrg", "HRVirtualMachineTemplate", armscvmm.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) - } - 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 = armscvmm.VirtualMachineTemplate{ - // Name: to.Ptr("HRVirtualMachineTemplate"), - // Type: to.Ptr("Microsoft.SCVMM/VirtualMachineTemplates"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachineTemplates/HRVirtualMachineTemplate"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VirtualMachineTemplateProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-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 := armscvmm.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.VirtualMachineTemplateListResult = armscvmm.VirtualMachineTemplateListResult{ - // Value: []*armscvmm.VirtualMachineTemplate{ - // { - // Name: to.Ptr("HRVirtualMachineTemplate"), - // Type: to.Ptr("Microsoft.SCVMM/VirtualMachineTemplates"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachineTemplates/HRVirtualMachineTemplate"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VirtualMachineTemplateProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListVirtualMachineTemplatesBySubscription.json -func ExampleVirtualMachineTemplatesClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVirtualMachineTemplatesClient().NewListBySubscriptionPager(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.VirtualMachineTemplateListResult = armscvmm.VirtualMachineTemplateListResult{ - // Value: []*armscvmm.VirtualMachineTemplate{ - // { - // Name: to.Ptr("HRVirtualMachineTemplate"), - // Type: to.Ptr("Microsoft.SCVMM/VirtualMachineTemplates"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachineTemplates/HRVirtualMachineTemplate"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VirtualMachineTemplateProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/scvmm/armscvmm/virtualnetworks_client.go b/sdk/resourcemanager/scvmm/armscvmm/virtualnetworks_client.go index f931d02cb143..fd4acca640f4 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/virtualnetworks_client.go +++ b/sdk/resourcemanager/scvmm/armscvmm/virtualnetworks_client.go @@ -17,7 +17,6 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" - "strconv" "strings" ) @@ -29,7 +28,7 @@ type VirtualNetworksClient struct { } // NewVirtualNetworksClient creates a new instance of VirtualNetworksClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewVirtualNetworksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualNetworksClient, error) { @@ -47,15 +46,15 @@ func NewVirtualNetworksClient(subscriptionID string, credential azcore.TokenCred // BeginCreateOrUpdate - Onboards the ScVmm virtual network as an Azure virtual network resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - virtualNetworkName - Name of the VirtualNetwork. -// - body - Request payload. +// - resource - Resource create parameters. // - options - VirtualNetworksClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualNetworksClient.BeginCreateOrUpdate // method. -func (client *VirtualNetworksClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkName string, body VirtualNetwork, options *VirtualNetworksClientBeginCreateOrUpdateOptions) (*runtime.Poller[VirtualNetworksClientCreateOrUpdateResponse], error) { +func (client *VirtualNetworksClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkName string, resource VirtualNetwork, options *VirtualNetworksClientBeginCreateOrUpdateOptions) (*runtime.Poller[VirtualNetworksClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.createOrUpdate(ctx, resourceGroupName, virtualNetworkName, body, options) + resp, err := client.createOrUpdate(ctx, resourceGroupName, virtualNetworkName, resource, options) if err != nil { return nil, err } @@ -74,14 +73,14 @@ func (client *VirtualNetworksClient) BeginCreateOrUpdate(ctx context.Context, re // CreateOrUpdate - Onboards the ScVmm virtual network as an Azure virtual network resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -func (client *VirtualNetworksClient) createOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkName string, body VirtualNetwork, options *VirtualNetworksClientBeginCreateOrUpdateOptions) (*http.Response, error) { +// Generated from API version 2024-06-01 +func (client *VirtualNetworksClient) createOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkName string, resource VirtualNetwork, options *VirtualNetworksClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "VirtualNetworksClient.BeginCreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, virtualNetworkName, body, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, virtualNetworkName, resource, options) if err != nil { return nil, err } @@ -97,7 +96,7 @@ func (client *VirtualNetworksClient) createOrUpdate(ctx context.Context, resourc } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *VirtualNetworksClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, virtualNetworkName string, body VirtualNetwork, options *VirtualNetworksClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *VirtualNetworksClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, virtualNetworkName string, resource VirtualNetwork, options *VirtualNetworksClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -116,10 +115,10 @@ func (client *VirtualNetworksClient) createOrUpdateCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, body); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil @@ -128,8 +127,8 @@ func (client *VirtualNetworksClient) createOrUpdateCreateRequest(ctx context.Con // BeginDelete - Deregisters the ScVmm virtual network from Azure. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - virtualNetworkName - Name of the VirtualNetwork. // - options - VirtualNetworksClientBeginDeleteOptions contains the optional parameters for the VirtualNetworksClient.BeginDelete // method. @@ -154,7 +153,7 @@ func (client *VirtualNetworksClient) BeginDelete(ctx context.Context, resourceGr // Delete - Deregisters the ScVmm virtual network from Azure. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview +// Generated from API version 2024-06-01 func (client *VirtualNetworksClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualNetworkName string, options *VirtualNetworksClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "VirtualNetworksClient.BeginDelete" @@ -169,7 +168,7 @@ func (client *VirtualNetworksClient) deleteOperation(ctx context.Context, resour if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -196,9 +195,9 @@ func (client *VirtualNetworksClient) deleteCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") if options != nil && options.Force != nil { - reqQP.Set("force", strconv.FormatBool(*options.Force)) + reqQP.Set("force", string(*options.Force)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} @@ -208,8 +207,8 @@ func (client *VirtualNetworksClient) deleteCreateRequest(ctx context.Context, re // Get - Implements VirtualNetwork GET method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - virtualNetworkName - Name of the VirtualNetwork. // - 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) { @@ -254,7 +253,7 @@ func (client *VirtualNetworksClient) getCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -271,8 +270,8 @@ func (client *VirtualNetworksClient) getHandleResponse(resp *http.Response) (Vir // NewListByResourceGroupPager - List of VirtualNetworks in a resource group. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - VirtualNetworksClientListByResourceGroupOptions contains the optional parameters for the VirtualNetworksClient.NewListByResourceGroupPager // method. func (client *VirtualNetworksClient) NewListByResourceGroupPager(resourceGroupName string, options *VirtualNetworksClientListByResourceGroupOptions) *runtime.Pager[VirtualNetworksClientListByResourceGroupResponse] { @@ -314,7 +313,7 @@ func (client *VirtualNetworksClient) listByResourceGroupCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -331,7 +330,7 @@ func (client *VirtualNetworksClient) listByResourceGroupHandleResponse(resp *htt // NewListBySubscriptionPager - List of VirtualNetworks in a subscription. // -// Generated from API version 2020-06-05-preview +// Generated from API version 2024-06-01 // - options - VirtualNetworksClientListBySubscriptionOptions contains the optional parameters for the VirtualNetworksClient.NewListBySubscriptionPager // method. func (client *VirtualNetworksClient) NewListBySubscriptionPager(options *VirtualNetworksClientListBySubscriptionOptions) *runtime.Pager[VirtualNetworksClientListBySubscriptionResponse] { @@ -369,7 +368,7 @@ func (client *VirtualNetworksClient) listBySubscriptionCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -387,15 +386,15 @@ func (client *VirtualNetworksClient) listBySubscriptionHandleResponse(resp *http // BeginUpdate - Updates the VirtualNetworks resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - virtualNetworkName - Name of the VirtualNetwork. -// - body - VirtualNetworks patch payload. +// - properties - The resource properties to be updated. // - options - VirtualNetworksClientBeginUpdateOptions contains the optional parameters for the VirtualNetworksClient.BeginUpdate // method. -func (client *VirtualNetworksClient) BeginUpdate(ctx context.Context, resourceGroupName string, virtualNetworkName string, body ResourcePatch, options *VirtualNetworksClientBeginUpdateOptions) (*runtime.Poller[VirtualNetworksClientUpdateResponse], error) { +func (client *VirtualNetworksClient) BeginUpdate(ctx context.Context, resourceGroupName string, virtualNetworkName string, properties VirtualNetworkTagsUpdate, options *VirtualNetworksClientBeginUpdateOptions) (*runtime.Poller[VirtualNetworksClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.update(ctx, resourceGroupName, virtualNetworkName, body, options) + resp, err := client.update(ctx, resourceGroupName, virtualNetworkName, properties, options) if err != nil { return nil, err } @@ -414,14 +413,14 @@ func (client *VirtualNetworksClient) BeginUpdate(ctx context.Context, resourceGr // Update - Updates the VirtualNetworks resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -func (client *VirtualNetworksClient) update(ctx context.Context, resourceGroupName string, virtualNetworkName string, body ResourcePatch, options *VirtualNetworksClientBeginUpdateOptions) (*http.Response, error) { +// Generated from API version 2024-06-01 +func (client *VirtualNetworksClient) update(ctx context.Context, resourceGroupName string, virtualNetworkName string, properties VirtualNetworkTagsUpdate, options *VirtualNetworksClientBeginUpdateOptions) (*http.Response, error) { var err error const operationName = "VirtualNetworksClient.BeginUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, resourceGroupName, virtualNetworkName, body, options) + req, err := client.updateCreateRequest(ctx, resourceGroupName, virtualNetworkName, properties, options) if err != nil { return nil, err } @@ -429,7 +428,7 @@ func (client *VirtualNetworksClient) update(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -437,16 +436,16 @@ func (client *VirtualNetworksClient) update(ctx context.Context, resourceGroupNa } // updateCreateRequest creates the Update request. -func (client *VirtualNetworksClient) updateCreateRequest(ctx context.Context, resourceGroupName string, virtualNetworkName string, body ResourcePatch, options *VirtualNetworksClientBeginUpdateOptions) (*policy.Request, error) { +func (client *VirtualNetworksClient) updateCreateRequest(ctx context.Context, resourceGroupName string, virtualNetworkName string, properties VirtualNetworkTagsUpdate, options *VirtualNetworksClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/virtualNetworks/{virtualNetworkName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 virtualNetworkName == "" { return nil, errors.New("parameter virtualNetworkName cannot be empty") } @@ -456,10 +455,10 @@ func (client *VirtualNetworksClient) updateCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, body); err != nil { + if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } return req, nil diff --git a/sdk/resourcemanager/scvmm/armscvmm/virtualnetworks_client_example_test.go b/sdk/resourcemanager/scvmm/armscvmm/virtualnetworks_client_example_test.go deleted file mode 100644 index a1a4acb36d2c..000000000000 --- a/sdk/resourcemanager/scvmm/armscvmm/virtualnetworks_client_example_test.go +++ /dev/null @@ -1,258 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// 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 armscvmm_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/scvmm/armscvmm" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-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 := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVirtualNetworksClient().Get(ctx, "testrg", "HRVirtualNetwork", 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 = armscvmm.VirtualNetwork{ - // Name: to.Ptr("HRVirtualNetwork"), - // Type: to.Ptr("Microsoft.SCVMM/VirtualNetworks"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualNetworks/HRVirtualNetwork"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VirtualNetworkProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/CreateVirtualNetwork.json -func ExampleVirtualNetworksClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualNetworksClient().BeginCreateOrUpdate(ctx, "testrg", "HRVirtualNetwork", armscvmm.VirtualNetwork{ - ExtendedLocation: &armscvmm.ExtendedLocation{ - Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - Type: to.Ptr("customLocation"), - }, - Location: to.Ptr("East US"), - Properties: &armscvmm.VirtualNetworkProperties{ - UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - }, - }, 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 = armscvmm.VirtualNetwork{ - // Name: to.Ptr("HRVirtualNetwork"), - // Type: to.Ptr("Microsoft.SCVMM/VirtualNetworks"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualNetworks/HRVirtualNetwork"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VirtualNetworkProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-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 := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualNetworksClient().BeginDelete(ctx, "testrg", "HRVirtualNetwork", &armscvmm.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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/UpdateVirtualNetwork.json -func ExampleVirtualNetworksClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVirtualNetworksClient().BeginUpdate(ctx, "testrg", "HRVirtualNetwork", armscvmm.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) - } - 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 = armscvmm.VirtualNetwork{ - // Name: to.Ptr("HRVirtualNetwork"), - // Type: to.Ptr("Microsoft.SCVMM/VirtualNetworks"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualNetworks/HRVirtualNetwork"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VirtualNetworkProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-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 := armscvmm.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.VirtualNetworkListResult = armscvmm.VirtualNetworkListResult{ - // Value: []*armscvmm.VirtualNetwork{ - // { - // Name: to.Ptr("HRVirtualNetwork"), - // Type: to.Ptr("Microsoft.SCVMM/VirtualNetworks"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualNetworks/HRVirtualNetwork"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VirtualNetworkProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListVirtualNetworksBySubscription.json -func ExampleVirtualNetworksClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVirtualNetworksClient().NewListBySubscriptionPager(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.VirtualNetworkListResult = armscvmm.VirtualNetworkListResult{ - // Value: []*armscvmm.VirtualNetwork{ - // { - // Name: to.Ptr("HRVirtualNetwork"), - // Type: to.Ptr("Microsoft.SCVMM/VirtualNetworks"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualNetworks/HRVirtualNetwork"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VirtualNetworkProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - // VmmServerID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/scvmm/armscvmm/vminstancehybrididentitymetadatas_client.go b/sdk/resourcemanager/scvmm/armscvmm/vminstancehybrididentitymetadatas_client.go new file mode 100644 index 000000000000..5b63a4eb8026 --- /dev/null +++ b/sdk/resourcemanager/scvmm/armscvmm/vminstancehybrididentitymetadatas_client.go @@ -0,0 +1,145 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armscvmm + +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" +) + +// VMInstanceHybridIdentityMetadatasClient contains the methods for the VMInstanceHybridIdentityMetadatas group. +// Don't use this type directly, use NewVMInstanceHybridIdentityMetadatasClient() instead. +type VMInstanceHybridIdentityMetadatasClient struct { + internal *arm.Client +} + +// NewVMInstanceHybridIdentityMetadatasClient creates a new instance of VMInstanceHybridIdentityMetadatasClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewVMInstanceHybridIdentityMetadatasClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*VMInstanceHybridIdentityMetadatasClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &VMInstanceHybridIdentityMetadatasClient{ + internal: cl, + } + return client, nil +} + +// Get - Implements HybridIdentityMetadata GET method. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-06-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - options - VMInstanceHybridIdentityMetadatasClientGetOptions contains the optional parameters for the VMInstanceHybridIdentityMetadatasClient.Get +// method. +func (client *VMInstanceHybridIdentityMetadatasClient) Get(ctx context.Context, resourceURI string, options *VMInstanceHybridIdentityMetadatasClientGetOptions) (VMInstanceHybridIdentityMetadatasClientGetResponse, error) { + var err error + const operationName = "VMInstanceHybridIdentityMetadatasClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceURI, options) + if err != nil { + return VMInstanceHybridIdentityMetadatasClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VMInstanceHybridIdentityMetadatasClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VMInstanceHybridIdentityMetadatasClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *VMInstanceHybridIdentityMetadatasClient) getCreateRequest(ctx context.Context, resourceURI string, options *VMInstanceHybridIdentityMetadatasClientGetOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ScVmm/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", "2024-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VMInstanceHybridIdentityMetadatasClient) getHandleResponse(resp *http.Response) (VMInstanceHybridIdentityMetadatasClientGetResponse, error) { + result := VMInstanceHybridIdentityMetadatasClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VMInstanceHybridIdentityMetadata); err != nil { + return VMInstanceHybridIdentityMetadatasClientGetResponse{}, err + } + return result, nil +} + +// NewListByVirtualMachineInstancePager - Returns the list of HybridIdentityMetadata of the given VM. +// +// Generated from API version 2024-06-01 +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - options - VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceOptions contains the optional parameters for +// the VMInstanceHybridIdentityMetadatasClient.NewListByVirtualMachineInstancePager method. +func (client *VMInstanceHybridIdentityMetadatasClient) NewListByVirtualMachineInstancePager(resourceURI string, options *VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceOptions) *runtime.Pager[VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceResponse] { + return runtime.NewPager(runtime.PagingHandler[VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceResponse]{ + More: func(page VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceResponse) (VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VMInstanceHybridIdentityMetadatasClient.NewListByVirtualMachineInstancePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByVirtualMachineInstanceCreateRequest(ctx, resourceURI, options) + }, nil) + if err != nil { + return VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceResponse{}, err + } + return client.listByVirtualMachineInstanceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByVirtualMachineInstanceCreateRequest creates the ListByVirtualMachineInstance request. +func (client *VMInstanceHybridIdentityMetadatasClient) listByVirtualMachineInstanceCreateRequest(ctx context.Context, resourceURI string, options *VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.ScVmm/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", "2024-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByVirtualMachineInstanceHandleResponse handles the ListByVirtualMachineInstance response. +func (client *VMInstanceHybridIdentityMetadatasClient) listByVirtualMachineInstanceHandleResponse(resp *http.Response) (VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceResponse, error) { + result := VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VMInstanceHybridIdentityMetadataListResult); err != nil { + return VMInstanceHybridIdentityMetadatasClientListByVirtualMachineInstanceResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/scvmm/armscvmm/vmmservers_client.go b/sdk/resourcemanager/scvmm/armscvmm/vmmservers_client.go index 6cac7ffee884..0fe0192fadfe 100644 --- a/sdk/resourcemanager/scvmm/armscvmm/vmmservers_client.go +++ b/sdk/resourcemanager/scvmm/armscvmm/vmmservers_client.go @@ -17,7 +17,6 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" - "strconv" "strings" ) @@ -29,7 +28,7 @@ type VmmServersClient struct { } // NewVmmServersClient creates a new instance of VmmServersClient with the specified values. -// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewVmmServersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VmmServersClient, error) { @@ -44,18 +43,18 @@ func NewVmmServersClient(subscriptionID string, credential azcore.TokenCredentia return client, nil } -// BeginCreateOrUpdate - Onboards the SCVMM fabric as an Azure VmmServer resource. +// BeginCreateOrUpdate - Onboards the SCVmm fabric as an Azure VmmServer resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - vmmServerName - Name of the VMMServer. -// - body - Request payload. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vmmServerName - Name of the VmmServer. +// - resource - Resource create parameters. // - options - VmmServersClientBeginCreateOrUpdateOptions contains the optional parameters for the VmmServersClient.BeginCreateOrUpdate // method. -func (client *VmmServersClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, vmmServerName string, body VMMServer, options *VmmServersClientBeginCreateOrUpdateOptions) (*runtime.Poller[VmmServersClientCreateOrUpdateResponse], error) { +func (client *VmmServersClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, vmmServerName string, resource VmmServer, options *VmmServersClientBeginCreateOrUpdateOptions) (*runtime.Poller[VmmServersClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.createOrUpdate(ctx, resourceGroupName, vmmServerName, body, options) + resp, err := client.createOrUpdate(ctx, resourceGroupName, vmmServerName, resource, options) if err != nil { return nil, err } @@ -71,17 +70,17 @@ func (client *VmmServersClient) BeginCreateOrUpdate(ctx context.Context, resourc } } -// CreateOrUpdate - Onboards the SCVMM fabric as an Azure VmmServer resource. +// CreateOrUpdate - Onboards the SCVmm fabric as an Azure VmmServer resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -func (client *VmmServersClient) createOrUpdate(ctx context.Context, resourceGroupName string, vmmServerName string, body VMMServer, options *VmmServersClientBeginCreateOrUpdateOptions) (*http.Response, error) { +// Generated from API version 2024-06-01 +func (client *VmmServersClient) createOrUpdate(ctx context.Context, resourceGroupName string, vmmServerName string, resource VmmServer, options *VmmServersClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "VmmServersClient.BeginCreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, vmmServerName, body, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, vmmServerName, resource, options) if err != nil { return nil, err } @@ -97,7 +96,7 @@ func (client *VmmServersClient) createOrUpdate(ctx context.Context, resourceGrou } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *VmmServersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, body VMMServer, options *VmmServersClientBeginCreateOrUpdateOptions) (*policy.Request, error) { +func (client *VmmServersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, resource VmmServer, options *VmmServersClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -116,21 +115,21 @@ func (client *VmmServersClient) createOrUpdateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, body); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil } -// BeginDelete - Deboards the SCVMM fabric from Azure. +// BeginDelete - Removes the SCVmm fabric from Azure. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - vmmServerName - Name of the VMMServer. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vmmServerName - Name of the VmmServer. // - options - VmmServersClientBeginDeleteOptions contains the optional parameters for the VmmServersClient.BeginDelete method. func (client *VmmServersClient) BeginDelete(ctx context.Context, resourceGroupName string, vmmServerName string, options *VmmServersClientBeginDeleteOptions) (*runtime.Poller[VmmServersClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { @@ -150,10 +149,10 @@ func (client *VmmServersClient) BeginDelete(ctx context.Context, resourceGroupNa } } -// Delete - Deboards the SCVMM fabric from Azure. +// Delete - Removes the SCVmm fabric from Azure. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview +// Generated from API version 2024-06-01 func (client *VmmServersClient) deleteOperation(ctx context.Context, resourceGroupName string, vmmServerName string, options *VmmServersClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "VmmServersClient.BeginDelete" @@ -168,7 +167,7 @@ func (client *VmmServersClient) deleteOperation(ctx context.Context, resourceGro if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -195,21 +194,21 @@ func (client *VmmServersClient) deleteCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") if options != nil && options.Force != nil { - reqQP.Set("force", strconv.FormatBool(*options.Force)) + reqQP.Set("force", string(*options.Force)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// Get - Implements VMMServer GET method. +// Get - Implements VmmServer GET method. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - vmmServerName - Name of the VMMServer. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vmmServerName - Name of the VmmServer. // - options - VmmServersClientGetOptions contains the optional parameters for the VmmServersClient.Get method. func (client *VmmServersClient) Get(ctx context.Context, resourceGroupName string, vmmServerName string, options *VmmServersClientGetOptions) (VmmServersClientGetResponse, error) { var err error @@ -253,7 +252,7 @@ func (client *VmmServersClient) getCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -262,7 +261,7 @@ func (client *VmmServersClient) getCreateRequest(ctx context.Context, resourceGr // getHandleResponse handles the Get response. func (client *VmmServersClient) getHandleResponse(resp *http.Response) (VmmServersClientGetResponse, error) { result := VmmServersClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VMMServer); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.VmmServer); err != nil { return VmmServersClientGetResponse{}, err } return result, nil @@ -270,8 +269,8 @@ func (client *VmmServersClient) getHandleResponse(resp *http.Response) (VmmServe // NewListByResourceGroupPager - List of VmmServers in a resource group. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - VmmServersClientListByResourceGroupOptions contains the optional parameters for the VmmServersClient.NewListByResourceGroupPager // method. func (client *VmmServersClient) NewListByResourceGroupPager(resourceGroupName string, options *VmmServersClientListByResourceGroupOptions) *runtime.Pager[VmmServersClientListByResourceGroupResponse] { @@ -313,7 +312,7 @@ func (client *VmmServersClient) listByResourceGroupCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -322,7 +321,7 @@ func (client *VmmServersClient) listByResourceGroupCreateRequest(ctx context.Con // listByResourceGroupHandleResponse handles the ListByResourceGroup response. func (client *VmmServersClient) listByResourceGroupHandleResponse(resp *http.Response) (VmmServersClientListByResourceGroupResponse, error) { result := VmmServersClientListByResourceGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VMMServerListResult); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.VmmServerListResult); err != nil { return VmmServersClientListByResourceGroupResponse{}, err } return result, nil @@ -330,7 +329,7 @@ func (client *VmmServersClient) listByResourceGroupHandleResponse(resp *http.Res // NewListBySubscriptionPager - List of VmmServers in a subscription. // -// Generated from API version 2020-06-05-preview +// Generated from API version 2024-06-01 // - options - VmmServersClientListBySubscriptionOptions contains the optional parameters for the VmmServersClient.NewListBySubscriptionPager // method. func (client *VmmServersClient) NewListBySubscriptionPager(options *VmmServersClientListBySubscriptionOptions) *runtime.Pager[VmmServersClientListBySubscriptionResponse] { @@ -368,7 +367,7 @@ func (client *VmmServersClient) listBySubscriptionCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -377,7 +376,7 @@ func (client *VmmServersClient) listBySubscriptionCreateRequest(ctx context.Cont // listBySubscriptionHandleResponse handles the ListBySubscription response. func (client *VmmServersClient) listBySubscriptionHandleResponse(resp *http.Response) (VmmServersClientListBySubscriptionResponse, error) { result := VmmServersClientListBySubscriptionResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VMMServerListResult); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.VmmServerListResult); err != nil { return VmmServersClientListBySubscriptionResponse{}, err } return result, nil @@ -386,14 +385,14 @@ func (client *VmmServersClient) listBySubscriptionHandleResponse(resp *http.Resp // BeginUpdate - Updates the VmmServers resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -// - resourceGroupName - The name of the resource group. -// - vmmServerName - Name of the VMMServer. -// - body - VmmServers patch payload. +// Generated from API version 2024-06-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vmmServerName - Name of the VmmServer. +// - properties - The resource properties to be updated. // - options - VmmServersClientBeginUpdateOptions contains the optional parameters for the VmmServersClient.BeginUpdate method. -func (client *VmmServersClient) BeginUpdate(ctx context.Context, resourceGroupName string, vmmServerName string, body ResourcePatch, options *VmmServersClientBeginUpdateOptions) (*runtime.Poller[VmmServersClientUpdateResponse], error) { +func (client *VmmServersClient) BeginUpdate(ctx context.Context, resourceGroupName string, vmmServerName string, properties VmmServerTagsUpdate, options *VmmServersClientBeginUpdateOptions) (*runtime.Poller[VmmServersClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.update(ctx, resourceGroupName, vmmServerName, body, options) + resp, err := client.update(ctx, resourceGroupName, vmmServerName, properties, options) if err != nil { return nil, err } @@ -412,14 +411,14 @@ func (client *VmmServersClient) BeginUpdate(ctx context.Context, resourceGroupNa // Update - Updates the VmmServers resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-06-05-preview -func (client *VmmServersClient) update(ctx context.Context, resourceGroupName string, vmmServerName string, body ResourcePatch, options *VmmServersClientBeginUpdateOptions) (*http.Response, error) { +// Generated from API version 2024-06-01 +func (client *VmmServersClient) update(ctx context.Context, resourceGroupName string, vmmServerName string, properties VmmServerTagsUpdate, options *VmmServersClientBeginUpdateOptions) (*http.Response, error) { var err error const operationName = "VmmServersClient.BeginUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, resourceGroupName, vmmServerName, body, options) + req, err := client.updateCreateRequest(ctx, resourceGroupName, vmmServerName, properties, options) if err != nil { return nil, err } @@ -427,7 +426,7 @@ func (client *VmmServersClient) update(ctx context.Context, resourceGroupName st if err != nil { return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) return nil, err } @@ -435,16 +434,16 @@ func (client *VmmServersClient) update(ctx context.Context, resourceGroupName st } // updateCreateRequest creates the Update request. -func (client *VmmServersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, body ResourcePatch, options *VmmServersClientBeginUpdateOptions) (*policy.Request, error) { +func (client *VmmServersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, vmmServerName string, properties VmmServerTagsUpdate, options *VmmServersClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ScVmm/vmmServers/{vmmServerName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) 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 vmmServerName == "" { return nil, errors.New("parameter vmmServerName cannot be empty") } @@ -454,10 +453,10 @@ func (client *VmmServersClient) updateCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-06-05-preview") + reqQP.Set("api-version", "2024-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, body); err != nil { + if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } return req, nil diff --git a/sdk/resourcemanager/scvmm/armscvmm/vmmservers_client_example_test.go b/sdk/resourcemanager/scvmm/armscvmm/vmmservers_client_example_test.go deleted file mode 100644 index 1d04bcea1e8b..000000000000 --- a/sdk/resourcemanager/scvmm/armscvmm/vmmservers_client_example_test.go +++ /dev/null @@ -1,277 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// 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 armscvmm_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/scvmm/armscvmm" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/GetVMMServer.json -func ExampleVmmServersClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVmmServersClient().Get(ctx, "testrg", "ContosoVMMServer", 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.VMMServer = armscvmm.VMMServer{ - // Name: to.Ptr("ContosoVMMServer"), - // Type: to.Ptr("Microsoft.SCVMM/VMMServers"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VMMServerProperties{ - // ConnectionStatus: to.Ptr("Connected"), - // Fqdn: to.Ptr("VMM.contoso.com"), - // Port: to.Ptr[int32](1234), - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("fd3c3665-1729-4b7b-9a38-238e83b0f98b"), - // Version: to.Ptr("2.0"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/CreateVMMServer.json -func ExampleVmmServersClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVmmServersClient().BeginCreateOrUpdate(ctx, "testrg", "ContosoVMMServer", armscvmm.VMMServer{ - ExtendedLocation: &armscvmm.ExtendedLocation{ - Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - Type: to.Ptr("customLocation"), - }, - Location: to.Ptr("East US"), - Properties: &armscvmm.VMMServerProperties{ - Credentials: &armscvmm.VMMServerPropertiesCredentials{ - Password: to.Ptr("password"), - Username: to.Ptr("testuser"), - }, - Fqdn: to.Ptr("VMM.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.VMMServer = armscvmm.VMMServer{ - // Name: to.Ptr("ContosoVMMServer"), - // Type: to.Ptr("Microsoft.SCVMM/VMMServers"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VMMServerProperties{ - // ConnectionStatus: to.Ptr("Connected"), - // Fqdn: to.Ptr("VMM.contoso.com"), - // Port: to.Ptr[int32](1234), - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("fd3c3665-1729-4b7b-9a38-238e83b0f98b"), - // Version: to.Ptr("2.0"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/DeleteVMMServer.json -func ExampleVmmServersClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVmmServersClient().BeginDelete(ctx, "testrg", "ContosoVMMServer", &armscvmm.VmmServersClientBeginDeleteOptions{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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/UpdateVMMServer.json -func ExampleVmmServersClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewVmmServersClient().BeginUpdate(ctx, "testrg", "ContosoVMMServer", armscvmm.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) - } - 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.VMMServer = armscvmm.VMMServer{ - // Name: to.Ptr("ContosoVMMServer"), - // Type: to.Ptr("Microsoft.SCVMM/VMMServers"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VMMServerProperties{ - // ConnectionStatus: to.Ptr("Connected"), - // Fqdn: to.Ptr("VMM.contoso.com"), - // Port: to.Ptr[int32](1234), - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("fd3c3665-1729-4b7b-9a38-238e83b0f98b"), - // Version: to.Ptr("2.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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListVMMServersByResourceGroup.json -func ExampleVmmServersClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVmmServersClient().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.VMMServerListResult = armscvmm.VMMServerListResult{ - // Value: []*armscvmm.VMMServer{ - // { - // Name: to.Ptr("ContosoVMMServer"), - // Type: to.Ptr("Microsoft.SCVMM/VMMServers"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VMMServerProperties{ - // ConnectionStatus: to.Ptr("Connected"), - // Fqdn: to.Ptr("VMM.contoso.com"), - // Port: to.Ptr[int32](1234), - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("fd3c3665-1729-4b7b-9a38-238e83b0f98b"), - // Version: to.Ptr("2.0"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/scvmm/resource-manager/Microsoft.ScVmm/preview/2020-06-05-preview/examples/ListVMMServersBySubscription.json -func ExampleVmmServersClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armscvmm.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVmmServersClient().NewListBySubscriptionPager(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.VMMServerListResult = armscvmm.VMMServerListResult{ - // Value: []*armscvmm.VMMServer{ - // { - // Name: to.Ptr("ContosoVMMServer"), - // Type: to.Ptr("Microsoft.SCVMM/VMMServers"), - // ExtendedLocation: &armscvmm.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso"), - // Type: to.Ptr("customLocation"), - // }, - // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - // Location: to.Ptr("East US"), - // Properties: &armscvmm.VMMServerProperties{ - // ConnectionStatus: to.Ptr("Connected"), - // Fqdn: to.Ptr("VMM.contoso.com"), - // Port: to.Ptr[int32](1234), - // ProvisioningState: to.Ptr("Succeeded"), - // UUID: to.Ptr("fd3c3665-1729-4b7b-9a38-238e83b0f98b"), - // Version: to.Ptr("2.0"), - // }, - // }}, - // } - } -}