diff --git a/resource-manager/azurestackhci/2023-09-01-preview/client.go b/resource-manager/azurestackhci/2023-09-01-preview/client.go new file mode 100644 index 00000000000..582ccab1f32 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/client.go @@ -0,0 +1,100 @@ +package v2023_09_01_preview + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/galleryimages" + "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/guestagents" + "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata" + "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks" + "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages" + "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks" + "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + GalleryImages *galleryimages.GalleryImagesClient + GuestAgents *guestagents.GuestAgentsClient + HybridIdentityMetadata *hybrididentitymetadata.HybridIdentityMetadataClient + LogicalNetworks *logicalnetworks.LogicalNetworksClient + MarketplaceGalleryImages *marketplacegalleryimages.MarketplaceGalleryImagesClient + NetworkInterfaces *networkinterfaces.NetworkInterfacesClient + StorageContainers *storagecontainers.StorageContainersClient + VirtualHardDisks *virtualharddisks.VirtualHardDisksClient + VirtualMachineInstances *virtualmachineinstances.VirtualMachineInstancesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + galleryImagesClient, err := galleryimages.NewGalleryImagesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building GalleryImages client: %+v", err) + } + configureFunc(galleryImagesClient.Client) + + guestAgentsClient, err := guestagents.NewGuestAgentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building GuestAgents client: %+v", err) + } + configureFunc(guestAgentsClient.Client) + + hybridIdentityMetadataClient, err := hybrididentitymetadata.NewHybridIdentityMetadataClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building HybridIdentityMetadata client: %+v", err) + } + configureFunc(hybridIdentityMetadataClient.Client) + + logicalNetworksClient, err := logicalnetworks.NewLogicalNetworksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building LogicalNetworks client: %+v", err) + } + configureFunc(logicalNetworksClient.Client) + + marketplaceGalleryImagesClient, err := marketplacegalleryimages.NewMarketplaceGalleryImagesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building MarketplaceGalleryImages client: %+v", err) + } + configureFunc(marketplaceGalleryImagesClient.Client) + + networkInterfacesClient, err := networkinterfaces.NewNetworkInterfacesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkInterfaces client: %+v", err) + } + configureFunc(networkInterfacesClient.Client) + + storageContainersClient, err := storagecontainers.NewStorageContainersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building StorageContainers client: %+v", err) + } + configureFunc(storageContainersClient.Client) + + virtualHardDisksClient, err := virtualharddisks.NewVirtualHardDisksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VirtualHardDisks client: %+v", err) + } + configureFunc(virtualHardDisksClient.Client) + + virtualMachineInstancesClient, err := virtualmachineinstances.NewVirtualMachineInstancesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VirtualMachineInstances client: %+v", err) + } + configureFunc(virtualMachineInstancesClient.Client) + + return &Client{ + GalleryImages: galleryImagesClient, + GuestAgents: guestAgentsClient, + HybridIdentityMetadata: hybridIdentityMetadataClient, + LogicalNetworks: logicalNetworksClient, + MarketplaceGalleryImages: marketplaceGalleryImagesClient, + NetworkInterfaces: networkInterfacesClient, + StorageContainers: storageContainersClient, + VirtualHardDisks: virtualHardDisksClient, + VirtualMachineInstances: virtualMachineInstancesClient, + }, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/README.md b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/README.md new file mode 100644 index 00000000000..36dfac2652a --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/galleryimages` Documentation + +The `galleryimages` SDK allows for interaction with the Azure Resource Manager Service `azurestackhci` (API Version `2023-09-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/galleryimages" +``` + + +### Client Initialization + +```go +client := galleryimages.NewGalleryImagesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `GalleryImagesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := galleryimages.NewGalleryImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "galleryImageValue") + +payload := galleryimages.GalleryImages{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `GalleryImagesClient.Delete` + +```go +ctx := context.TODO() +id := galleryimages.NewGalleryImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "galleryImageValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `GalleryImagesClient.Get` + +```go +ctx := context.TODO() +id := galleryimages.NewGalleryImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "galleryImageValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `GalleryImagesClient.List` + +```go +ctx := context.TODO() +id := galleryimages.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `GalleryImagesClient.ListAll` + +```go +ctx := context.TODO() +id := galleryimages.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `GalleryImagesClient.Update` + +```go +ctx := context.TODO() +id := galleryimages.NewGalleryImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "galleryImageValue") + +payload := galleryimages.GalleryImagesUpdateRequest{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/client.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/client.go new file mode 100644 index 00000000000..59b9c848dbd --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/client.go @@ -0,0 +1,26 @@ +package galleryimages + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryImagesClient struct { + Client *resourcemanager.Client +} + +func NewGalleryImagesClientWithBaseURI(sdkApi sdkEnv.Api) (*GalleryImagesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "galleryimages", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GalleryImagesClient: %+v", err) + } + + return &GalleryImagesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/constants.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/constants.go new file mode 100644 index 00000000000..57bfe8f301b --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/constants.go @@ -0,0 +1,268 @@ +package galleryimages + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudInitDataSource string + +const ( + CloudInitDataSourceAzure CloudInitDataSource = "Azure" + CloudInitDataSourceNoCloud CloudInitDataSource = "NoCloud" +) + +func PossibleValuesForCloudInitDataSource() []string { + return []string{ + string(CloudInitDataSourceAzure), + string(CloudInitDataSourceNoCloud), + } +} + +func (s *CloudInitDataSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudInitDataSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudInitDataSource(input string) (*CloudInitDataSource, error) { + vals := map[string]CloudInitDataSource{ + "azure": CloudInitDataSourceAzure, + "nocloud": CloudInitDataSourceNoCloud, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudInitDataSource(input) + return &out, nil +} + +type ExtendedLocationTypes string + +const ( + ExtendedLocationTypesCustomLocation ExtendedLocationTypes = "CustomLocation" +) + +func PossibleValuesForExtendedLocationTypes() []string { + return []string{ + string(ExtendedLocationTypesCustomLocation), + } +} + +func (s *ExtendedLocationTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExtendedLocationTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExtendedLocationTypes(input string) (*ExtendedLocationTypes, error) { + vals := map[string]ExtendedLocationTypes{ + "customlocation": ExtendedLocationTypesCustomLocation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExtendedLocationTypes(input) + return &out, nil +} + +type HyperVGeneration string + +const ( + HyperVGenerationVOne HyperVGeneration = "V1" + HyperVGenerationVTwo HyperVGeneration = "V2" +) + +func PossibleValuesForHyperVGeneration() []string { + return []string{ + string(HyperVGenerationVOne), + string(HyperVGenerationVTwo), + } +} + +func (s *HyperVGeneration) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHyperVGeneration(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHyperVGeneration(input string) (*HyperVGeneration, error) { + vals := map[string]HyperVGeneration{ + "v1": HyperVGenerationVOne, + "v2": HyperVGenerationVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HyperVGeneration(input) + return &out, nil +} + +type OperatingSystemTypes string + +const ( + OperatingSystemTypesLinux OperatingSystemTypes = "Linux" + OperatingSystemTypesWindows OperatingSystemTypes = "Windows" +) + +func PossibleValuesForOperatingSystemTypes() []string { + return []string{ + string(OperatingSystemTypesLinux), + string(OperatingSystemTypesWindows), + } +} + +func (s *OperatingSystemTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperatingSystemTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperatingSystemTypes(input string) (*OperatingSystemTypes, error) { + vals := map[string]OperatingSystemTypes{ + "linux": OperatingSystemTypesLinux, + "windows": OperatingSystemTypesWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperatingSystemTypes(input) + return &out, nil +} + +type ProvisioningStateEnum string + +const ( + ProvisioningStateEnumAccepted ProvisioningStateEnum = "Accepted" + ProvisioningStateEnumCanceled ProvisioningStateEnum = "Canceled" + ProvisioningStateEnumDeleting ProvisioningStateEnum = "Deleting" + ProvisioningStateEnumFailed ProvisioningStateEnum = "Failed" + ProvisioningStateEnumInProgress ProvisioningStateEnum = "InProgress" + ProvisioningStateEnumSucceeded ProvisioningStateEnum = "Succeeded" +) + +func PossibleValuesForProvisioningStateEnum() []string { + return []string{ + string(ProvisioningStateEnumAccepted), + string(ProvisioningStateEnumCanceled), + string(ProvisioningStateEnumDeleting), + string(ProvisioningStateEnumFailed), + string(ProvisioningStateEnumInProgress), + string(ProvisioningStateEnumSucceeded), + } +} + +func (s *ProvisioningStateEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningStateEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningStateEnum(input string) (*ProvisioningStateEnum, error) { + vals := map[string]ProvisioningStateEnum{ + "accepted": ProvisioningStateEnumAccepted, + "canceled": ProvisioningStateEnumCanceled, + "deleting": ProvisioningStateEnumDeleting, + "failed": ProvisioningStateEnumFailed, + "inprogress": ProvisioningStateEnumInProgress, + "succeeded": ProvisioningStateEnumSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningStateEnum(input) + return &out, nil +} + +type Status string + +const ( + StatusFailed Status = "Failed" + StatusInProgress Status = "InProgress" + StatusSucceeded Status = "Succeeded" +) + +func PossibleValuesForStatus() []string { + return []string{ + string(StatusFailed), + string(StatusInProgress), + string(StatusSucceeded), + } +} + +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatus(input string) (*Status, error) { + vals := map[string]Status{ + "failed": StatusFailed, + "inprogress": StatusInProgress, + "succeeded": StatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Status(input) + return &out, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/id_galleryimage.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/id_galleryimage.go new file mode 100644 index 00000000000..a35eb568df7 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/id_galleryimage.go @@ -0,0 +1,125 @@ +package galleryimages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &GalleryImageId{} + +// GalleryImageId is a struct representing the Resource ID for a Gallery Image +type GalleryImageId struct { + SubscriptionId string + ResourceGroupName string + GalleryImageName string +} + +// NewGalleryImageID returns a new GalleryImageId struct +func NewGalleryImageID(subscriptionId string, resourceGroupName string, galleryImageName string) GalleryImageId { + return GalleryImageId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + GalleryImageName: galleryImageName, + } +} + +// ParseGalleryImageID parses 'input' into a GalleryImageId +func ParseGalleryImageID(input string) (*GalleryImageId, error) { + parser := resourceids.NewParserFromResourceIdType(&GalleryImageId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GalleryImageId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseGalleryImageIDInsensitively parses 'input' case-insensitively into a GalleryImageId +// note: this method should only be used for API response data and not user input +func ParseGalleryImageIDInsensitively(input string) (*GalleryImageId, error) { + parser := resourceids.NewParserFromResourceIdType(&GalleryImageId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GalleryImageId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *GalleryImageId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.GalleryImageName, ok = input.Parsed["galleryImageName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "galleryImageName", input) + } + + return nil +} + +// ValidateGalleryImageID checks that 'input' can be parsed as a Gallery Image ID +func ValidateGalleryImageID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseGalleryImageID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Gallery Image ID +func (id GalleryImageId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AzureStackHCI/galleryImages/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.GalleryImageName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Gallery Image ID +func (id GalleryImageId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAzureStackHCI", "Microsoft.AzureStackHCI", "Microsoft.AzureStackHCI"), + resourceids.StaticSegment("staticGalleryImages", "galleryImages", "galleryImages"), + resourceids.UserSpecifiedSegment("galleryImageName", "galleryImageValue"), + } +} + +// String returns a human-readable description of this Gallery Image ID +func (id GalleryImageId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Gallery Image Name: %q", id.GalleryImageName), + } + return fmt.Sprintf("Gallery Image (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/id_galleryimage_test.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/id_galleryimage_test.go new file mode 100644 index 00000000000..0051a069209 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/id_galleryimage_test.go @@ -0,0 +1,282 @@ +package galleryimages + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &GalleryImageId{} + +func TestNewGalleryImageID(t *testing.T) { + id := NewGalleryImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "galleryImageValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.GalleryImageName != "galleryImageValue" { + t.Fatalf("Expected %q but got %q for Segment 'GalleryImageName'", id.GalleryImageName, "galleryImageValue") + } +} + +func TestFormatGalleryImageID(t *testing.T) { + actual := NewGalleryImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "galleryImageValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/galleryImages/galleryImageValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseGalleryImageID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GalleryImageId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/galleryImages", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/galleryImages/galleryImageValue", + Expected: &GalleryImageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + GalleryImageName: "galleryImageValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/galleryImages/galleryImageValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGalleryImageID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.GalleryImageName != v.Expected.GalleryImageName { + t.Fatalf("Expected %q but got %q for GalleryImageName", v.Expected.GalleryImageName, actual.GalleryImageName) + } + + } +} + +func TestParseGalleryImageIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GalleryImageId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/galleryImages", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/gAlLeRyImAgEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/galleryImages/galleryImageValue", + Expected: &GalleryImageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + GalleryImageName: "galleryImageValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/galleryImages/galleryImageValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/gAlLeRyImAgEs/gAlLeRyImAgEvAlUe", + Expected: &GalleryImageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + GalleryImageName: "gAlLeRyImAgEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/gAlLeRyImAgEs/gAlLeRyImAgEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGalleryImageIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.GalleryImageName != v.Expected.GalleryImageName { + t.Fatalf("Expected %q but got %q for GalleryImageName", v.Expected.GalleryImageName, actual.GalleryImageName) + } + + } +} + +func TestSegmentsForGalleryImageId(t *testing.T) { + segments := GalleryImageId{}.Segments() + if len(segments) == 0 { + t.Fatalf("GalleryImageId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_createorupdate.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_createorupdate.go new file mode 100644 index 00000000000..b127187ac8a --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_createorupdate.go @@ -0,0 +1,74 @@ +package galleryimages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdate ... +func (c GalleryImagesClient) CreateOrUpdate(ctx context.Context, id GalleryImageId, input GalleryImages) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c GalleryImagesClient) CreateOrUpdateThenPoll(ctx context.Context, id GalleryImageId, input GalleryImages) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_delete.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_delete.go new file mode 100644 index 00000000000..635a0f9294d --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_delete.go @@ -0,0 +1,70 @@ +package galleryimages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c GalleryImagesClient) Delete(ctx context.Context, id GalleryImageId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c GalleryImagesClient) DeleteThenPoll(ctx context.Context, id GalleryImageId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_get.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_get.go new file mode 100644 index 00000000000..f2fcf6de5fb --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_get.go @@ -0,0 +1,51 @@ +package galleryimages + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GalleryImages +} + +// Get ... +func (c GalleryImagesClient) Get(ctx context.Context, id GalleryImageId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_list.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_list.go new file mode 100644 index 00000000000..e171f62e8ce --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_list.go @@ -0,0 +1,92 @@ +package galleryimages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GalleryImages +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []GalleryImages +} + +// List ... +func (c GalleryImagesClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/galleryImages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GalleryImages `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c GalleryImagesClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, GalleryImagesOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GalleryImagesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate GalleryImagesOperationPredicate) (result ListCompleteResult, err error) { + items := make([]GalleryImages, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_listall.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_listall.go new file mode 100644 index 00000000000..e39e2388d80 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_listall.go @@ -0,0 +1,92 @@ +package galleryimages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GalleryImages +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []GalleryImages +} + +// ListAll ... +func (c GalleryImagesClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/galleryImages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GalleryImages `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c GalleryImagesClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, GalleryImagesOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GalleryImagesClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate GalleryImagesOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]GalleryImages, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_update.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_update.go new file mode 100644 index 00000000000..0e822eb72ea --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/method_update.go @@ -0,0 +1,74 @@ +package galleryimages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c GalleryImagesClient) Update(ctx context.Context, id GalleryImageId, input GalleryImagesUpdateRequest) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c GalleryImagesClient) UpdateThenPoll(ctx context.Context, id GalleryImageId, input GalleryImagesUpdateRequest) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_extendedlocation.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_extendedlocation.go new file mode 100644 index 00000000000..de4007c5034 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_extendedlocation.go @@ -0,0 +1,9 @@ +package galleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *ExtendedLocationTypes `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_gallerydiskimage.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_gallerydiskimage.go new file mode 100644 index 00000000000..9586c039d4d --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_gallerydiskimage.go @@ -0,0 +1,8 @@ +package galleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryDiskImage struct { + SizeInMB *int64 `json:"sizeInMB,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimageidentifier.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimageidentifier.go new file mode 100644 index 00000000000..c4ba59a4105 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimageidentifier.go @@ -0,0 +1,10 @@ +package galleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryImageIdentifier struct { + Offer string `json:"offer"` + Publisher string `json:"publisher"` + Sku string `json:"sku"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimageproperties.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimageproperties.go new file mode 100644 index 00000000000..01b92688cc8 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimageproperties.go @@ -0,0 +1,16 @@ +package galleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryImageProperties struct { + CloudInitDataSource *CloudInitDataSource `json:"cloudInitDataSource,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + HyperVGeneration *HyperVGeneration `json:"hyperVGeneration,omitempty"` + Identifier *GalleryImageIdentifier `json:"identifier,omitempty"` + ImagePath *string `json:"imagePath,omitempty"` + OsType OperatingSystemTypes `json:"osType"` + ProvisioningState *ProvisioningStateEnum `json:"provisioningState,omitempty"` + Status *GalleryImageStatus `json:"status,omitempty"` + Version *GalleryImageVersion `json:"version,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimages.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimages.go new file mode 100644 index 00000000000..2822280c55b --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimages.go @@ -0,0 +1,19 @@ +package galleryimages + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryImages struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *GalleryImageProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimagestatus.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimagestatus.go new file mode 100644 index 00000000000..8a966e4b8f0 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimagestatus.go @@ -0,0 +1,12 @@ +package galleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryImageStatus struct { + DownloadStatus *GalleryImageStatusDownloadStatus `json:"downloadStatus,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ProgressPercentage *int64 `json:"progressPercentage,omitempty"` + ProvisioningStatus *GalleryImageStatusProvisioningStatus `json:"provisioningStatus,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimagestatusdownloadstatus.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimagestatusdownloadstatus.go new file mode 100644 index 00000000000..c395a6d3a9a --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimagestatusdownloadstatus.go @@ -0,0 +1,8 @@ +package galleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryImageStatusDownloadStatus struct { + DownloadSizeInMB *int64 `json:"downloadSizeInMB,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimagestatusprovisioningstatus.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimagestatusprovisioningstatus.go new file mode 100644 index 00000000000..b28f2566755 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimagestatusprovisioningstatus.go @@ -0,0 +1,9 @@ +package galleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryImageStatusProvisioningStatus struct { + OperationId *string `json:"operationId,omitempty"` + Status *Status `json:"status,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimagesupdaterequest.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimagesupdaterequest.go new file mode 100644 index 00000000000..9e6dd0452e8 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimagesupdaterequest.go @@ -0,0 +1,8 @@ +package galleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryImagesUpdateRequest struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimageversion.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimageversion.go new file mode 100644 index 00000000000..13ec192bd64 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimageversion.go @@ -0,0 +1,9 @@ +package galleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryImageVersion struct { + Name *string `json:"name,omitempty"` + Properties *GalleryImageVersionProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimageversionproperties.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimageversionproperties.go new file mode 100644 index 00000000000..3790dd0595a --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimageversionproperties.go @@ -0,0 +1,8 @@ +package galleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryImageVersionProperties struct { + StorageProfile GalleryImageVersionStorageProfile `json:"storageProfile"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimageversionstorageprofile.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimageversionstorageprofile.go new file mode 100644 index 00000000000..c6775223724 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/model_galleryimageversionstorageprofile.go @@ -0,0 +1,8 @@ +package galleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryImageVersionStorageProfile struct { + OsDiskImage *GalleryDiskImage `json:"osDiskImage,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/predicates.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/predicates.go new file mode 100644 index 00000000000..63c56669688 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/predicates.go @@ -0,0 +1,32 @@ +package galleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryImagesOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p GalleryImagesOperationPredicate) Matches(input GalleryImages) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/version.go b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/version.go new file mode 100644 index 00000000000..ae078f48a6d --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/galleryimages/version.go @@ -0,0 +1,12 @@ +package galleryimages + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/galleryimages/%s", defaultApiVersion) +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/guestagents/README.md b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/README.md new file mode 100644 index 00000000000..c67cce140ec --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/guestagents` Documentation + +The `guestagents` SDK allows for interaction with the Azure Resource Manager Service `azurestackhci` (API Version `2023-09-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/guestagents" +``` + + +### Client Initialization + +```go +client := guestagents.NewGuestAgentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `GuestAgentsClient.GuestAgentCreate` + +```go +ctx := context.TODO() +id := guestagents.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +payload := guestagents.GuestAgent{ + // ... +} + + +if err := client.GuestAgentCreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `GuestAgentsClient.GuestAgentDelete` + +```go +ctx := context.TODO() +id := guestagents.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +if err := client.GuestAgentDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `GuestAgentsClient.GuestAgentGet` + +```go +ctx := context.TODO() +id := guestagents.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +read, err := client.GuestAgentGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `GuestAgentsClient.List` + +```go +ctx := context.TODO() +id := guestagents.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/azurestackhci/2023-09-01-preview/guestagents/client.go b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/client.go new file mode 100644 index 00000000000..8b3899fa940 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/client.go @@ -0,0 +1,26 @@ +package guestagents + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GuestAgentsClient struct { + Client *resourcemanager.Client +} + +func NewGuestAgentsClientWithBaseURI(sdkApi sdkEnv.Api) (*GuestAgentsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "guestagents", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GuestAgentsClient: %+v", err) + } + + return &GuestAgentsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/guestagents/constants.go b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/constants.go new file mode 100644 index 00000000000..148c2721b51 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/constants.go @@ -0,0 +1,54 @@ +package guestagents + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningAction string + +const ( + ProvisioningActionInstall ProvisioningAction = "install" + ProvisioningActionRepair ProvisioningAction = "repair" + ProvisioningActionUninstall ProvisioningAction = "uninstall" +) + +func PossibleValuesForProvisioningAction() []string { + return []string{ + string(ProvisioningActionInstall), + string(ProvisioningActionRepair), + string(ProvisioningActionUninstall), + } +} + +func (s *ProvisioningAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningAction(input string) (*ProvisioningAction, error) { + vals := map[string]ProvisioningAction{ + "install": ProvisioningActionInstall, + "repair": ProvisioningActionRepair, + "uninstall": ProvisioningActionUninstall, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningAction(input) + return &out, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/guestagents/method_guestagentcreate.go b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/method_guestagentcreate.go new file mode 100644 index 00000000000..7368584217d --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/method_guestagentcreate.go @@ -0,0 +1,75 @@ +package guestagents + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GuestAgentCreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// GuestAgentCreate ... +func (c GuestAgentsClient) GuestAgentCreate(ctx context.Context, id commonids.ScopeId, input GuestAgent) (result GuestAgentCreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/guestAgents/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GuestAgentCreateThenPoll performs GuestAgentCreate then polls until it's completed +func (c GuestAgentsClient) GuestAgentCreateThenPoll(ctx context.Context, id commonids.ScopeId, input GuestAgent) error { + result, err := c.GuestAgentCreate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing GuestAgentCreate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GuestAgentCreate: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/guestagents/method_guestagentdelete.go b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/method_guestagentdelete.go new file mode 100644 index 00000000000..7f9080a2a63 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/method_guestagentdelete.go @@ -0,0 +1,71 @@ +package guestagents + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GuestAgentDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// GuestAgentDelete ... +func (c GuestAgentsClient) GuestAgentDelete(ctx context.Context, id commonids.ScopeId) (result GuestAgentDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/guestAgents/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GuestAgentDeleteThenPoll performs GuestAgentDelete then polls until it's completed +func (c GuestAgentsClient) GuestAgentDeleteThenPoll(ctx context.Context, id commonids.ScopeId) error { + result, err := c.GuestAgentDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing GuestAgentDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GuestAgentDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/guestagents/method_guestagentget.go b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/method_guestagentget.go new file mode 100644 index 00000000000..2c88b4e2655 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/method_guestagentget.go @@ -0,0 +1,53 @@ +package guestagents + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GuestAgentGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GuestAgent +} + +// GuestAgentGet ... +func (c GuestAgentsClient) GuestAgentGet(ctx context.Context, id commonids.ScopeId) (result GuestAgentGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/guestAgents/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/guestagents/method_list.go b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/method_list.go new file mode 100644 index 00000000000..05786b10336 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/method_list.go @@ -0,0 +1,92 @@ +package guestagents + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GuestAgent +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []GuestAgent +} + +// List ... +func (c GuestAgentsClient) List(ctx context.Context, id commonids.ScopeId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/guestAgents", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GuestAgent `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c GuestAgentsClient) ListComplete(ctx context.Context, id commonids.ScopeId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, GuestAgentOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GuestAgentsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ScopeId, predicate GuestAgentOperationPredicate) (result ListCompleteResult, err error) { + items := make([]GuestAgent, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/guestagents/model_guestagent.go b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/model_guestagent.go new file mode 100644 index 00000000000..9614c14071c --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/model_guestagent.go @@ -0,0 +1,16 @@ +package guestagents + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GuestAgent struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties GuestAgentProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/guestagents/model_guestagentproperties.go b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/model_guestagentproperties.go new file mode 100644 index 00000000000..7e671a9f75b --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/model_guestagentproperties.go @@ -0,0 +1,11 @@ +package guestagents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GuestAgentProperties struct { + Credentials *GuestCredential `json:"credentials,omitempty"` + ProvisioningAction *ProvisioningAction `json:"provisioningAction,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/guestagents/model_guestcredential.go b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/model_guestcredential.go new file mode 100644 index 00000000000..98dcf0b76f4 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/model_guestcredential.go @@ -0,0 +1,9 @@ +package guestagents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GuestCredential struct { + Password *string `json:"password,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/guestagents/predicates.go b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/predicates.go new file mode 100644 index 00000000000..f51a9dcf2c9 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/predicates.go @@ -0,0 +1,27 @@ +package guestagents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GuestAgentOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p GuestAgentOperationPredicate) Matches(input GuestAgent) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/guestagents/version.go b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/version.go new file mode 100644 index 00000000000..2c04bfe4f0a --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/guestagents/version.go @@ -0,0 +1,12 @@ +package guestagents + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/guestagents/%s", defaultApiVersion) +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/README.md b/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/README.md new file mode 100644 index 00000000000..51f4a76db7b --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata` Documentation + +The `hybrididentitymetadata` SDK allows for interaction with the Azure Resource Manager Service `azurestackhci` (API Version `2023-09-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata" +``` + + +### Client Initialization + +```go +client := hybrididentitymetadata.NewHybridIdentityMetadataClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `HybridIdentityMetadataClient.Get` + +```go +ctx := context.TODO() +id := hybrididentitymetadata.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `HybridIdentityMetadataClient.List` + +```go +ctx := context.TODO() +id := hybrididentitymetadata.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/client.go b/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/client.go new file mode 100644 index 00000000000..597657e5901 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/client.go @@ -0,0 +1,26 @@ +package hybrididentitymetadata + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridIdentityMetadataClient struct { + Client *resourcemanager.Client +} + +func NewHybridIdentityMetadataClientWithBaseURI(sdkApi sdkEnv.Api) (*HybridIdentityMetadataClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "hybrididentitymetadata", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating HybridIdentityMetadataClient: %+v", err) + } + + return &HybridIdentityMetadataClient{ + Client: client, + }, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/method_get.go b/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/method_get.go new file mode 100644 index 00000000000..f5248d13c5b --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/method_get.go @@ -0,0 +1,53 @@ +package hybrididentitymetadata + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridIdentityMetadata +} + +// Get ... +func (c HybridIdentityMetadataClient) Get(ctx context.Context, id commonids.ScopeId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/hybridIdentityMetadata/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/method_list.go b/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/method_list.go new file mode 100644 index 00000000000..12cf31659ea --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/method_list.go @@ -0,0 +1,92 @@ +package hybrididentitymetadata + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HybridIdentityMetadata +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []HybridIdentityMetadata +} + +// List ... +func (c HybridIdentityMetadataClient) List(ctx context.Context, id commonids.ScopeId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/hybridIdentityMetadata", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]HybridIdentityMetadata `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c HybridIdentityMetadataClient) ListComplete(ctx context.Context, id commonids.ScopeId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, HybridIdentityMetadataOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c HybridIdentityMetadataClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ScopeId, predicate HybridIdentityMetadataOperationPredicate) (result ListCompleteResult, err error) { + items := make([]HybridIdentityMetadata, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/model_hybrididentitymetadata.go b/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/model_hybrididentitymetadata.go new file mode 100644 index 00000000000..301219b821b --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/model_hybrididentitymetadata.go @@ -0,0 +1,16 @@ +package hybrididentitymetadata + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridIdentityMetadata struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties HybridIdentityMetadataProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/model_hybrididentitymetadataproperties.go b/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/model_hybrididentitymetadataproperties.go new file mode 100644 index 00000000000..b04d4756658 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/model_hybrididentitymetadataproperties.go @@ -0,0 +1,15 @@ +package hybrididentitymetadata + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridIdentityMetadataProperties struct { + Identity *identity.SystemAssigned `json:"identity,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + PublicKey *string `json:"publicKey,omitempty"` + ResourceUid *string `json:"resourceUid,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/predicates.go b/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/predicates.go new file mode 100644 index 00000000000..5e9f9c439d5 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/predicates.go @@ -0,0 +1,27 @@ +package hybrididentitymetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridIdentityMetadataOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p HybridIdentityMetadataOperationPredicate) Matches(input HybridIdentityMetadata) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/version.go b/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/version.go new file mode 100644 index 00000000000..df1b600862b --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/hybrididentitymetadata/version.go @@ -0,0 +1,12 @@ +package hybrididentitymetadata + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/hybrididentitymetadata/%s", defaultApiVersion) +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/README.md b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/README.md new file mode 100644 index 00000000000..1fa190d1bd6 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks` Documentation + +The `logicalnetworks` SDK allows for interaction with the Azure Resource Manager Service `azurestackhci` (API Version `2023-09-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks" +``` + + +### Client Initialization + +```go +client := logicalnetworks.NewLogicalNetworksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `LogicalNetworksClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := logicalnetworks.NewLogicalNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "logicalNetworkValue") + +payload := logicalnetworks.LogicalNetworks{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `LogicalNetworksClient.Delete` + +```go +ctx := context.TODO() +id := logicalnetworks.NewLogicalNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "logicalNetworkValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `LogicalNetworksClient.Get` + +```go +ctx := context.TODO() +id := logicalnetworks.NewLogicalNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "logicalNetworkValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LogicalNetworksClient.List` + +```go +ctx := context.TODO() +id := logicalnetworks.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `LogicalNetworksClient.ListAll` + +```go +ctx := context.TODO() +id := logicalnetworks.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `LogicalNetworksClient.Update` + +```go +ctx := context.TODO() +id := logicalnetworks.NewLogicalNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "logicalNetworkValue") + +payload := logicalnetworks.LogicalNetworksUpdateRequest{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/client.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/client.go new file mode 100644 index 00000000000..1ab7fafbcfe --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/client.go @@ -0,0 +1,26 @@ +package logicalnetworks + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogicalNetworksClient struct { + Client *resourcemanager.Client +} + +func NewLogicalNetworksClientWithBaseURI(sdkApi sdkEnv.Api) (*LogicalNetworksClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "logicalnetworks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LogicalNetworksClient: %+v", err) + } + + return &LogicalNetworksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/constants.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/constants.go new file mode 100644 index 00000000000..a67025636ed --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/constants.go @@ -0,0 +1,227 @@ +package logicalnetworks + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocationTypes string + +const ( + ExtendedLocationTypesCustomLocation ExtendedLocationTypes = "CustomLocation" +) + +func PossibleValuesForExtendedLocationTypes() []string { + return []string{ + string(ExtendedLocationTypesCustomLocation), + } +} + +func (s *ExtendedLocationTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExtendedLocationTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExtendedLocationTypes(input string) (*ExtendedLocationTypes, error) { + vals := map[string]ExtendedLocationTypes{ + "customlocation": ExtendedLocationTypesCustomLocation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExtendedLocationTypes(input) + return &out, nil +} + +type IPAllocationMethodEnum string + +const ( + IPAllocationMethodEnumDynamic IPAllocationMethodEnum = "Dynamic" + IPAllocationMethodEnumStatic IPAllocationMethodEnum = "Static" +) + +func PossibleValuesForIPAllocationMethodEnum() []string { + return []string{ + string(IPAllocationMethodEnumDynamic), + string(IPAllocationMethodEnumStatic), + } +} + +func (s *IPAllocationMethodEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethodEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethodEnum(input string) (*IPAllocationMethodEnum, error) { + vals := map[string]IPAllocationMethodEnum{ + "dynamic": IPAllocationMethodEnumDynamic, + "static": IPAllocationMethodEnumStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethodEnum(input) + return &out, nil +} + +type IPPoolTypeEnum string + +const ( + IPPoolTypeEnumVM IPPoolTypeEnum = "vm" + IPPoolTypeEnumVippool IPPoolTypeEnum = "vippool" +) + +func PossibleValuesForIPPoolTypeEnum() []string { + return []string{ + string(IPPoolTypeEnumVM), + string(IPPoolTypeEnumVippool), + } +} + +func (s *IPPoolTypeEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPPoolTypeEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPPoolTypeEnum(input string) (*IPPoolTypeEnum, error) { + vals := map[string]IPPoolTypeEnum{ + "vm": IPPoolTypeEnumVM, + "vippool": IPPoolTypeEnumVippool, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPPoolTypeEnum(input) + return &out, nil +} + +type ProvisioningStateEnum string + +const ( + ProvisioningStateEnumAccepted ProvisioningStateEnum = "Accepted" + ProvisioningStateEnumCanceled ProvisioningStateEnum = "Canceled" + ProvisioningStateEnumDeleting ProvisioningStateEnum = "Deleting" + ProvisioningStateEnumFailed ProvisioningStateEnum = "Failed" + ProvisioningStateEnumInProgress ProvisioningStateEnum = "InProgress" + ProvisioningStateEnumSucceeded ProvisioningStateEnum = "Succeeded" +) + +func PossibleValuesForProvisioningStateEnum() []string { + return []string{ + string(ProvisioningStateEnumAccepted), + string(ProvisioningStateEnumCanceled), + string(ProvisioningStateEnumDeleting), + string(ProvisioningStateEnumFailed), + string(ProvisioningStateEnumInProgress), + string(ProvisioningStateEnumSucceeded), + } +} + +func (s *ProvisioningStateEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningStateEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningStateEnum(input string) (*ProvisioningStateEnum, error) { + vals := map[string]ProvisioningStateEnum{ + "accepted": ProvisioningStateEnumAccepted, + "canceled": ProvisioningStateEnumCanceled, + "deleting": ProvisioningStateEnumDeleting, + "failed": ProvisioningStateEnumFailed, + "inprogress": ProvisioningStateEnumInProgress, + "succeeded": ProvisioningStateEnumSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningStateEnum(input) + return &out, nil +} + +type Status string + +const ( + StatusFailed Status = "Failed" + StatusInProgress Status = "InProgress" + StatusSucceeded Status = "Succeeded" +) + +func PossibleValuesForStatus() []string { + return []string{ + string(StatusFailed), + string(StatusInProgress), + string(StatusSucceeded), + } +} + +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatus(input string) (*Status, error) { + vals := map[string]Status{ + "failed": StatusFailed, + "inprogress": StatusInProgress, + "succeeded": StatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Status(input) + return &out, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/id_logicalnetwork.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/id_logicalnetwork.go new file mode 100644 index 00000000000..86568e87e01 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/id_logicalnetwork.go @@ -0,0 +1,125 @@ +package logicalnetworks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LogicalNetworkId{} + +// LogicalNetworkId is a struct representing the Resource ID for a Logical Network +type LogicalNetworkId struct { + SubscriptionId string + ResourceGroupName string + LogicalNetworkName string +} + +// NewLogicalNetworkID returns a new LogicalNetworkId struct +func NewLogicalNetworkID(subscriptionId string, resourceGroupName string, logicalNetworkName string) LogicalNetworkId { + return LogicalNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LogicalNetworkName: logicalNetworkName, + } +} + +// ParseLogicalNetworkID parses 'input' into a LogicalNetworkId +func ParseLogicalNetworkID(input string) (*LogicalNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&LogicalNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LogicalNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLogicalNetworkIDInsensitively parses 'input' case-insensitively into a LogicalNetworkId +// note: this method should only be used for API response data and not user input +func ParseLogicalNetworkIDInsensitively(input string) (*LogicalNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&LogicalNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LogicalNetworkId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LogicalNetworkId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LogicalNetworkName, ok = input.Parsed["logicalNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "logicalNetworkName", input) + } + + return nil +} + +// ValidateLogicalNetworkID checks that 'input' can be parsed as a Logical Network ID +func ValidateLogicalNetworkID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLogicalNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Logical Network ID +func (id LogicalNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AzureStackHCI/logicalNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LogicalNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Logical Network ID +func (id LogicalNetworkId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAzureStackHCI", "Microsoft.AzureStackHCI", "Microsoft.AzureStackHCI"), + resourceids.StaticSegment("staticLogicalNetworks", "logicalNetworks", "logicalNetworks"), + resourceids.UserSpecifiedSegment("logicalNetworkName", "logicalNetworkValue"), + } +} + +// String returns a human-readable description of this Logical Network ID +func (id LogicalNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Logical Network Name: %q", id.LogicalNetworkName), + } + return fmt.Sprintf("Logical Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/id_logicalnetwork_test.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/id_logicalnetwork_test.go new file mode 100644 index 00000000000..c2a4f46af95 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/id_logicalnetwork_test.go @@ -0,0 +1,282 @@ +package logicalnetworks + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LogicalNetworkId{} + +func TestNewLogicalNetworkID(t *testing.T) { + id := NewLogicalNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "logicalNetworkValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LogicalNetworkName != "logicalNetworkValue" { + t.Fatalf("Expected %q but got %q for Segment 'LogicalNetworkName'", id.LogicalNetworkName, "logicalNetworkValue") + } +} + +func TestFormatLogicalNetworkID(t *testing.T) { + actual := NewLogicalNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "logicalNetworkValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/logicalNetworks/logicalNetworkValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLogicalNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LogicalNetworkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/logicalNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/logicalNetworks/logicalNetworkValue", + Expected: &LogicalNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LogicalNetworkName: "logicalNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/logicalNetworks/logicalNetworkValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLogicalNetworkID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LogicalNetworkName != v.Expected.LogicalNetworkName { + t.Fatalf("Expected %q but got %q for LogicalNetworkName", v.Expected.LogicalNetworkName, actual.LogicalNetworkName) + } + + } +} + +func TestParseLogicalNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LogicalNetworkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/logicalNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/lOgIcAlNeTwOrKs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/logicalNetworks/logicalNetworkValue", + Expected: &LogicalNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LogicalNetworkName: "logicalNetworkValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/logicalNetworks/logicalNetworkValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/lOgIcAlNeTwOrKs/lOgIcAlNeTwOrKvAlUe", + Expected: &LogicalNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LogicalNetworkName: "lOgIcAlNeTwOrKvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/lOgIcAlNeTwOrKs/lOgIcAlNeTwOrKvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLogicalNetworkIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LogicalNetworkName != v.Expected.LogicalNetworkName { + t.Fatalf("Expected %q but got %q for LogicalNetworkName", v.Expected.LogicalNetworkName, actual.LogicalNetworkName) + } + + } +} + +func TestSegmentsForLogicalNetworkId(t *testing.T) { + segments := LogicalNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LogicalNetworkId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_createorupdate.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_createorupdate.go new file mode 100644 index 00000000000..fdd698753e6 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_createorupdate.go @@ -0,0 +1,74 @@ +package logicalnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdate ... +func (c LogicalNetworksClient) CreateOrUpdate(ctx context.Context, id LogicalNetworkId, input LogicalNetworks) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c LogicalNetworksClient) CreateOrUpdateThenPoll(ctx context.Context, id LogicalNetworkId, input LogicalNetworks) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_delete.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_delete.go new file mode 100644 index 00000000000..7a0b121dca6 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_delete.go @@ -0,0 +1,70 @@ +package logicalnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c LogicalNetworksClient) Delete(ctx context.Context, id LogicalNetworkId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c LogicalNetworksClient) DeleteThenPoll(ctx context.Context, id LogicalNetworkId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_get.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_get.go new file mode 100644 index 00000000000..7a0076904ce --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_get.go @@ -0,0 +1,51 @@ +package logicalnetworks + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LogicalNetworks +} + +// Get ... +func (c LogicalNetworksClient) Get(ctx context.Context, id LogicalNetworkId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_list.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_list.go new file mode 100644 index 00000000000..ac44ca1f776 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_list.go @@ -0,0 +1,92 @@ +package logicalnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LogicalNetworks +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []LogicalNetworks +} + +// List ... +func (c LogicalNetworksClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/logicalNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]LogicalNetworks `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c LogicalNetworksClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, LogicalNetworksOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LogicalNetworksClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate LogicalNetworksOperationPredicate) (result ListCompleteResult, err error) { + items := make([]LogicalNetworks, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_listall.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_listall.go new file mode 100644 index 00000000000..02e39aff2b8 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_listall.go @@ -0,0 +1,92 @@ +package logicalnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LogicalNetworks +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []LogicalNetworks +} + +// ListAll ... +func (c LogicalNetworksClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/logicalNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]LogicalNetworks `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c LogicalNetworksClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, LogicalNetworksOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LogicalNetworksClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate LogicalNetworksOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]LogicalNetworks, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_update.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_update.go new file mode 100644 index 00000000000..d0db35d9770 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/method_update.go @@ -0,0 +1,74 @@ +package logicalnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c LogicalNetworksClient) Update(ctx context.Context, id LogicalNetworkId, input LogicalNetworksUpdateRequest) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c LogicalNetworksClient) UpdateThenPoll(ctx context.Context, id LogicalNetworkId, input LogicalNetworksUpdateRequest) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_extendedlocation.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_extendedlocation.go new file mode 100644 index 00000000000..1b8aaf852e3 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_extendedlocation.go @@ -0,0 +1,9 @@ +package logicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *ExtendedLocationTypes `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_ippool.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_ippool.go new file mode 100644 index 00000000000..a38aebc47ca --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_ippool.go @@ -0,0 +1,12 @@ +package logicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPPool struct { + End *string `json:"end,omitempty"` + IPPoolType *IPPoolTypeEnum `json:"ipPoolType,omitempty"` + Info *IPPoolInfo `json:"info,omitempty"` + Name *string `json:"name,omitempty"` + Start *string `json:"start,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_ippoolinfo.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_ippoolinfo.go new file mode 100644 index 00000000000..ea018cf572c --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_ippoolinfo.go @@ -0,0 +1,9 @@ +package logicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPPoolInfo struct { + Available *string `json:"available,omitempty"` + Used *string `json:"used,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworkproperties.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworkproperties.go new file mode 100644 index 00000000000..82b4ee030f7 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworkproperties.go @@ -0,0 +1,12 @@ +package logicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogicalNetworkProperties struct { + DhcpOptions *LogicalNetworkPropertiesDhcpOptions `json:"dhcpOptions,omitempty"` + ProvisioningState *ProvisioningStateEnum `json:"provisioningState,omitempty"` + Status *LogicalNetworkStatus `json:"status,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` + VMSwitchName *string `json:"vmSwitchName,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworkpropertiesdhcpoptions.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworkpropertiesdhcpoptions.go new file mode 100644 index 00000000000..b7f824ae587 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworkpropertiesdhcpoptions.go @@ -0,0 +1,8 @@ +package logicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogicalNetworkPropertiesDhcpOptions struct { + DnsServers *[]string `json:"dnsServers,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworks.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworks.go new file mode 100644 index 00000000000..df65bd28854 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworks.go @@ -0,0 +1,19 @@ +package logicalnetworks + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogicalNetworks struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *LogicalNetworkProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworkstatus.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworkstatus.go new file mode 100644 index 00000000000..c4c6bfcb65d --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworkstatus.go @@ -0,0 +1,10 @@ +package logicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogicalNetworkStatus struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ProvisioningStatus *LogicalNetworkStatusProvisioningStatus `json:"provisioningStatus,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworkstatusprovisioningstatus.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworkstatusprovisioningstatus.go new file mode 100644 index 00000000000..4b42c07e7e8 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworkstatusprovisioningstatus.go @@ -0,0 +1,9 @@ +package logicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogicalNetworkStatusProvisioningStatus struct { + OperationId *string `json:"operationId,omitempty"` + Status *Status `json:"status,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworksupdaterequest.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworksupdaterequest.go new file mode 100644 index 00000000000..f3ea7229f10 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_logicalnetworksupdaterequest.go @@ -0,0 +1,8 @@ +package logicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogicalNetworksUpdateRequest struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_route.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_route.go new file mode 100644 index 00000000000..605cfd736c3 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_route.go @@ -0,0 +1,9 @@ +package logicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_routepropertiesformat.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_routepropertiesformat.go new file mode 100644 index 00000000000..77c4db98967 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_routepropertiesformat.go @@ -0,0 +1,9 @@ +package logicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_routetable.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_routetable.go new file mode 100644 index 00000000000..f0c1ba0b0b8 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_routetable.go @@ -0,0 +1,11 @@ +package logicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_routetablepropertiesformat.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..ade39099b0c --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_routetablepropertiesformat.go @@ -0,0 +1,8 @@ +package logicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + Routes *[]Route `json:"routes,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_subnet.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_subnet.go new file mode 100644 index 00000000000..ba19efff89a --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_subnet.go @@ -0,0 +1,9 @@ +package logicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_subnetpropertiesformat.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..cc1154dcad4 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_subnetpropertiesformat.go @@ -0,0 +1,14 @@ +package logicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + IPAllocationMethod *IPAllocationMethodEnum `json:"ipAllocationMethod,omitempty"` + IPConfigurationReferences *[]SubnetPropertiesFormatIPConfigurationReferencesInlined `json:"ipConfigurationReferences,omitempty"` + IPPools *[]IPPool `json:"ipPools,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + Vlan *int64 `json:"vlan,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_subnetpropertiesformatipconfigurationreferencesinlined.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_subnetpropertiesformatipconfigurationreferencesinlined.go new file mode 100644 index 00000000000..538aac7d7d8 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/model_subnetpropertiesformatipconfigurationreferencesinlined.go @@ -0,0 +1,8 @@ +package logicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormatIPConfigurationReferencesInlined struct { + ID *string `json:"ID,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/predicates.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/predicates.go new file mode 100644 index 00000000000..afe2fed4d99 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/predicates.go @@ -0,0 +1,32 @@ +package logicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogicalNetworksOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p LogicalNetworksOperationPredicate) Matches(input LogicalNetworks) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/version.go b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/version.go new file mode 100644 index 00000000000..0d4370fd389 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/logicalnetworks/version.go @@ -0,0 +1,12 @@ +package logicalnetworks + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/logicalnetworks/%s", defaultApiVersion) +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/README.md b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/README.md new file mode 100644 index 00000000000..ec18443f3ee --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages` Documentation + +The `marketplacegalleryimages` SDK allows for interaction with the Azure Resource Manager Service `azurestackhci` (API Version `2023-09-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages" +``` + + +### Client Initialization + +```go +client := marketplacegalleryimages.NewMarketplaceGalleryImagesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MarketplaceGalleryImagesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := marketplacegalleryimages.NewMarketplaceGalleryImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "marketplaceGalleryImageValue") + +payload := marketplacegalleryimages.MarketplaceGalleryImages{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `MarketplaceGalleryImagesClient.Delete` + +```go +ctx := context.TODO() +id := marketplacegalleryimages.NewMarketplaceGalleryImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "marketplaceGalleryImageValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `MarketplaceGalleryImagesClient.Get` + +```go +ctx := context.TODO() +id := marketplacegalleryimages.NewMarketplaceGalleryImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "marketplaceGalleryImageValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MarketplaceGalleryImagesClient.List` + +```go +ctx := context.TODO() +id := marketplacegalleryimages.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `MarketplaceGalleryImagesClient.ListAll` + +```go +ctx := context.TODO() +id := marketplacegalleryimages.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `MarketplaceGalleryImagesClient.Update` + +```go +ctx := context.TODO() +id := marketplacegalleryimages.NewMarketplaceGalleryImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "marketplaceGalleryImageValue") + +payload := marketplacegalleryimages.MarketplaceGalleryImagesUpdateRequest{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/client.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/client.go new file mode 100644 index 00000000000..d999cf677f8 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/client.go @@ -0,0 +1,26 @@ +package marketplacegalleryimages + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceGalleryImagesClient struct { + Client *resourcemanager.Client +} + +func NewMarketplaceGalleryImagesClientWithBaseURI(sdkApi sdkEnv.Api) (*MarketplaceGalleryImagesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "marketplacegalleryimages", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MarketplaceGalleryImagesClient: %+v", err) + } + + return &MarketplaceGalleryImagesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/constants.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/constants.go new file mode 100644 index 00000000000..d93c2349a0c --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/constants.go @@ -0,0 +1,268 @@ +package marketplacegalleryimages + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudInitDataSource string + +const ( + CloudInitDataSourceAzure CloudInitDataSource = "Azure" + CloudInitDataSourceNoCloud CloudInitDataSource = "NoCloud" +) + +func PossibleValuesForCloudInitDataSource() []string { + return []string{ + string(CloudInitDataSourceAzure), + string(CloudInitDataSourceNoCloud), + } +} + +func (s *CloudInitDataSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudInitDataSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudInitDataSource(input string) (*CloudInitDataSource, error) { + vals := map[string]CloudInitDataSource{ + "azure": CloudInitDataSourceAzure, + "nocloud": CloudInitDataSourceNoCloud, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudInitDataSource(input) + return &out, nil +} + +type ExtendedLocationTypes string + +const ( + ExtendedLocationTypesCustomLocation ExtendedLocationTypes = "CustomLocation" +) + +func PossibleValuesForExtendedLocationTypes() []string { + return []string{ + string(ExtendedLocationTypesCustomLocation), + } +} + +func (s *ExtendedLocationTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExtendedLocationTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExtendedLocationTypes(input string) (*ExtendedLocationTypes, error) { + vals := map[string]ExtendedLocationTypes{ + "customlocation": ExtendedLocationTypesCustomLocation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExtendedLocationTypes(input) + return &out, nil +} + +type HyperVGeneration string + +const ( + HyperVGenerationVOne HyperVGeneration = "V1" + HyperVGenerationVTwo HyperVGeneration = "V2" +) + +func PossibleValuesForHyperVGeneration() []string { + return []string{ + string(HyperVGenerationVOne), + string(HyperVGenerationVTwo), + } +} + +func (s *HyperVGeneration) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHyperVGeneration(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHyperVGeneration(input string) (*HyperVGeneration, error) { + vals := map[string]HyperVGeneration{ + "v1": HyperVGenerationVOne, + "v2": HyperVGenerationVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HyperVGeneration(input) + return &out, nil +} + +type OperatingSystemTypes string + +const ( + OperatingSystemTypesLinux OperatingSystemTypes = "Linux" + OperatingSystemTypesWindows OperatingSystemTypes = "Windows" +) + +func PossibleValuesForOperatingSystemTypes() []string { + return []string{ + string(OperatingSystemTypesLinux), + string(OperatingSystemTypesWindows), + } +} + +func (s *OperatingSystemTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperatingSystemTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperatingSystemTypes(input string) (*OperatingSystemTypes, error) { + vals := map[string]OperatingSystemTypes{ + "linux": OperatingSystemTypesLinux, + "windows": OperatingSystemTypesWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperatingSystemTypes(input) + return &out, nil +} + +type ProvisioningStateEnum string + +const ( + ProvisioningStateEnumAccepted ProvisioningStateEnum = "Accepted" + ProvisioningStateEnumCanceled ProvisioningStateEnum = "Canceled" + ProvisioningStateEnumDeleting ProvisioningStateEnum = "Deleting" + ProvisioningStateEnumFailed ProvisioningStateEnum = "Failed" + ProvisioningStateEnumInProgress ProvisioningStateEnum = "InProgress" + ProvisioningStateEnumSucceeded ProvisioningStateEnum = "Succeeded" +) + +func PossibleValuesForProvisioningStateEnum() []string { + return []string{ + string(ProvisioningStateEnumAccepted), + string(ProvisioningStateEnumCanceled), + string(ProvisioningStateEnumDeleting), + string(ProvisioningStateEnumFailed), + string(ProvisioningStateEnumInProgress), + string(ProvisioningStateEnumSucceeded), + } +} + +func (s *ProvisioningStateEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningStateEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningStateEnum(input string) (*ProvisioningStateEnum, error) { + vals := map[string]ProvisioningStateEnum{ + "accepted": ProvisioningStateEnumAccepted, + "canceled": ProvisioningStateEnumCanceled, + "deleting": ProvisioningStateEnumDeleting, + "failed": ProvisioningStateEnumFailed, + "inprogress": ProvisioningStateEnumInProgress, + "succeeded": ProvisioningStateEnumSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningStateEnum(input) + return &out, nil +} + +type Status string + +const ( + StatusFailed Status = "Failed" + StatusInProgress Status = "InProgress" + StatusSucceeded Status = "Succeeded" +) + +func PossibleValuesForStatus() []string { + return []string{ + string(StatusFailed), + string(StatusInProgress), + string(StatusSucceeded), + } +} + +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatus(input string) (*Status, error) { + vals := map[string]Status{ + "failed": StatusFailed, + "inprogress": StatusInProgress, + "succeeded": StatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Status(input) + return &out, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/id_marketplacegalleryimage.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/id_marketplacegalleryimage.go new file mode 100644 index 00000000000..bd8def2021d --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/id_marketplacegalleryimage.go @@ -0,0 +1,125 @@ +package marketplacegalleryimages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MarketplaceGalleryImageId{} + +// MarketplaceGalleryImageId is a struct representing the Resource ID for a Marketplace Gallery Image +type MarketplaceGalleryImageId struct { + SubscriptionId string + ResourceGroupName string + MarketplaceGalleryImageName string +} + +// NewMarketplaceGalleryImageID returns a new MarketplaceGalleryImageId struct +func NewMarketplaceGalleryImageID(subscriptionId string, resourceGroupName string, marketplaceGalleryImageName string) MarketplaceGalleryImageId { + return MarketplaceGalleryImageId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + MarketplaceGalleryImageName: marketplaceGalleryImageName, + } +} + +// ParseMarketplaceGalleryImageID parses 'input' into a MarketplaceGalleryImageId +func ParseMarketplaceGalleryImageID(input string) (*MarketplaceGalleryImageId, error) { + parser := resourceids.NewParserFromResourceIdType(&MarketplaceGalleryImageId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MarketplaceGalleryImageId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMarketplaceGalleryImageIDInsensitively parses 'input' case-insensitively into a MarketplaceGalleryImageId +// note: this method should only be used for API response data and not user input +func ParseMarketplaceGalleryImageIDInsensitively(input string) (*MarketplaceGalleryImageId, error) { + parser := resourceids.NewParserFromResourceIdType(&MarketplaceGalleryImageId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MarketplaceGalleryImageId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MarketplaceGalleryImageId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.MarketplaceGalleryImageName, ok = input.Parsed["marketplaceGalleryImageName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "marketplaceGalleryImageName", input) + } + + return nil +} + +// ValidateMarketplaceGalleryImageID checks that 'input' can be parsed as a Marketplace Gallery Image ID +func ValidateMarketplaceGalleryImageID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseMarketplaceGalleryImageID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Marketplace Gallery Image ID +func (id MarketplaceGalleryImageId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.MarketplaceGalleryImageName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Marketplace Gallery Image ID +func (id MarketplaceGalleryImageId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAzureStackHCI", "Microsoft.AzureStackHCI", "Microsoft.AzureStackHCI"), + resourceids.StaticSegment("staticMarketplaceGalleryImages", "marketplaceGalleryImages", "marketplaceGalleryImages"), + resourceids.UserSpecifiedSegment("marketplaceGalleryImageName", "marketplaceGalleryImageValue"), + } +} + +// String returns a human-readable description of this Marketplace Gallery Image ID +func (id MarketplaceGalleryImageId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Marketplace Gallery Image Name: %q", id.MarketplaceGalleryImageName), + } + return fmt.Sprintf("Marketplace Gallery Image (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/id_marketplacegalleryimage_test.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/id_marketplacegalleryimage_test.go new file mode 100644 index 00000000000..2efd70c631f --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/id_marketplacegalleryimage_test.go @@ -0,0 +1,282 @@ +package marketplacegalleryimages + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MarketplaceGalleryImageId{} + +func TestNewMarketplaceGalleryImageID(t *testing.T) { + id := NewMarketplaceGalleryImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "marketplaceGalleryImageValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.MarketplaceGalleryImageName != "marketplaceGalleryImageValue" { + t.Fatalf("Expected %q but got %q for Segment 'MarketplaceGalleryImageName'", id.MarketplaceGalleryImageName, "marketplaceGalleryImageValue") + } +} + +func TestFormatMarketplaceGalleryImageID(t *testing.T) { + actual := NewMarketplaceGalleryImageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "marketplaceGalleryImageValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/marketplaceGalleryImageValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMarketplaceGalleryImageID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MarketplaceGalleryImageId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/marketplaceGalleryImageValue", + Expected: &MarketplaceGalleryImageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MarketplaceGalleryImageName: "marketplaceGalleryImageValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/marketplaceGalleryImageValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMarketplaceGalleryImageID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.MarketplaceGalleryImageName != v.Expected.MarketplaceGalleryImageName { + t.Fatalf("Expected %q but got %q for MarketplaceGalleryImageName", v.Expected.MarketplaceGalleryImageName, actual.MarketplaceGalleryImageName) + } + + } +} + +func TestParseMarketplaceGalleryImageIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MarketplaceGalleryImageId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/mArKeTpLaCeGaLlErYiMaGeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/marketplaceGalleryImageValue", + Expected: &MarketplaceGalleryImageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + MarketplaceGalleryImageName: "marketplaceGalleryImageValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/marketplaceGalleryImageValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/mArKeTpLaCeGaLlErYiMaGeS/mArKeTpLaCeGaLlErYiMaGeVaLuE", + Expected: &MarketplaceGalleryImageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + MarketplaceGalleryImageName: "mArKeTpLaCeGaLlErYiMaGeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/mArKeTpLaCeGaLlErYiMaGeS/mArKeTpLaCeGaLlErYiMaGeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMarketplaceGalleryImageIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.MarketplaceGalleryImageName != v.Expected.MarketplaceGalleryImageName { + t.Fatalf("Expected %q but got %q for MarketplaceGalleryImageName", v.Expected.MarketplaceGalleryImageName, actual.MarketplaceGalleryImageName) + } + + } +} + +func TestSegmentsForMarketplaceGalleryImageId(t *testing.T) { + segments := MarketplaceGalleryImageId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MarketplaceGalleryImageId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_createorupdate.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_createorupdate.go new file mode 100644 index 00000000000..b1810c22972 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_createorupdate.go @@ -0,0 +1,74 @@ +package marketplacegalleryimages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdate ... +func (c MarketplaceGalleryImagesClient) CreateOrUpdate(ctx context.Context, id MarketplaceGalleryImageId, input MarketplaceGalleryImages) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c MarketplaceGalleryImagesClient) CreateOrUpdateThenPoll(ctx context.Context, id MarketplaceGalleryImageId, input MarketplaceGalleryImages) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_delete.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_delete.go new file mode 100644 index 00000000000..c9ef757cc54 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_delete.go @@ -0,0 +1,70 @@ +package marketplacegalleryimages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c MarketplaceGalleryImagesClient) Delete(ctx context.Context, id MarketplaceGalleryImageId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c MarketplaceGalleryImagesClient) DeleteThenPoll(ctx context.Context, id MarketplaceGalleryImageId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_get.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_get.go new file mode 100644 index 00000000000..863117c9293 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_get.go @@ -0,0 +1,51 @@ +package marketplacegalleryimages + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MarketplaceGalleryImages +} + +// Get ... +func (c MarketplaceGalleryImagesClient) Get(ctx context.Context, id MarketplaceGalleryImageId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_list.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_list.go new file mode 100644 index 00000000000..e7fd62764d1 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_list.go @@ -0,0 +1,92 @@ +package marketplacegalleryimages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MarketplaceGalleryImages +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []MarketplaceGalleryImages +} + +// List ... +func (c MarketplaceGalleryImagesClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MarketplaceGalleryImages `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c MarketplaceGalleryImagesClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, MarketplaceGalleryImagesOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MarketplaceGalleryImagesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate MarketplaceGalleryImagesOperationPredicate) (result ListCompleteResult, err error) { + items := make([]MarketplaceGalleryImages, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_listall.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_listall.go new file mode 100644 index 00000000000..fa398ccfe08 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_listall.go @@ -0,0 +1,92 @@ +package marketplacegalleryimages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MarketplaceGalleryImages +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []MarketplaceGalleryImages +} + +// ListAll ... +func (c MarketplaceGalleryImagesClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MarketplaceGalleryImages `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c MarketplaceGalleryImagesClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, MarketplaceGalleryImagesOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MarketplaceGalleryImagesClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate MarketplaceGalleryImagesOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]MarketplaceGalleryImages, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_update.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_update.go new file mode 100644 index 00000000000..974c5206083 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/method_update.go @@ -0,0 +1,74 @@ +package marketplacegalleryimages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c MarketplaceGalleryImagesClient) Update(ctx context.Context, id MarketplaceGalleryImageId, input MarketplaceGalleryImagesUpdateRequest) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c MarketplaceGalleryImagesClient) UpdateThenPoll(ctx context.Context, id MarketplaceGalleryImageId, input MarketplaceGalleryImagesUpdateRequest) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_extendedlocation.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_extendedlocation.go new file mode 100644 index 00000000000..53cadae95d5 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_extendedlocation.go @@ -0,0 +1,9 @@ +package marketplacegalleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *ExtendedLocationTypes `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_gallerydiskimage.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_gallerydiskimage.go new file mode 100644 index 00000000000..317f9e6cfb1 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_gallerydiskimage.go @@ -0,0 +1,8 @@ +package marketplacegalleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryDiskImage struct { + SizeInMB *int64 `json:"sizeInMB,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_galleryimageidentifier.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_galleryimageidentifier.go new file mode 100644 index 00000000000..0f3541e5338 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_galleryimageidentifier.go @@ -0,0 +1,10 @@ +package marketplacegalleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryImageIdentifier struct { + Offer string `json:"offer"` + Publisher string `json:"publisher"` + Sku string `json:"sku"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_galleryimageversion.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_galleryimageversion.go new file mode 100644 index 00000000000..ac6e38f6b41 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_galleryimageversion.go @@ -0,0 +1,9 @@ +package marketplacegalleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryImageVersion struct { + Name *string `json:"name,omitempty"` + Properties *GalleryImageVersionProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_galleryimageversionproperties.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_galleryimageversionproperties.go new file mode 100644 index 00000000000..c9ed2934420 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_galleryimageversionproperties.go @@ -0,0 +1,8 @@ +package marketplacegalleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryImageVersionProperties struct { + StorageProfile GalleryImageVersionStorageProfile `json:"storageProfile"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_galleryimageversionstorageprofile.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_galleryimageversionstorageprofile.go new file mode 100644 index 00000000000..74c0cb1cf13 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_galleryimageversionstorageprofile.go @@ -0,0 +1,8 @@ +package marketplacegalleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GalleryImageVersionStorageProfile struct { + OsDiskImage *GalleryDiskImage `json:"osDiskImage,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimageproperties.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimageproperties.go new file mode 100644 index 00000000000..97b773ae78f --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimageproperties.go @@ -0,0 +1,15 @@ +package marketplacegalleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceGalleryImageProperties struct { + CloudInitDataSource *CloudInitDataSource `json:"cloudInitDataSource,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + HyperVGeneration *HyperVGeneration `json:"hyperVGeneration,omitempty"` + Identifier *GalleryImageIdentifier `json:"identifier,omitempty"` + OsType OperatingSystemTypes `json:"osType"` + ProvisioningState *ProvisioningStateEnum `json:"provisioningState,omitempty"` + Status *MarketplaceGalleryImageStatus `json:"status,omitempty"` + Version *GalleryImageVersion `json:"version,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimages.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimages.go new file mode 100644 index 00000000000..cc450d9462f --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimages.go @@ -0,0 +1,19 @@ +package marketplacegalleryimages + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceGalleryImages struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *MarketplaceGalleryImageProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimagestatus.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimagestatus.go new file mode 100644 index 00000000000..527539725df --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimagestatus.go @@ -0,0 +1,12 @@ +package marketplacegalleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceGalleryImageStatus struct { + DownloadStatus *MarketplaceGalleryImageStatusDownloadStatus `json:"downloadStatus,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ProgressPercentage *int64 `json:"progressPercentage,omitempty"` + ProvisioningStatus *MarketplaceGalleryImageStatusProvisioningStatus `json:"provisioningStatus,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimagestatusdownloadstatus.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimagestatusdownloadstatus.go new file mode 100644 index 00000000000..85c57796050 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimagestatusdownloadstatus.go @@ -0,0 +1,8 @@ +package marketplacegalleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceGalleryImageStatusDownloadStatus struct { + DownloadSizeInMB *int64 `json:"downloadSizeInMB,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimagestatusprovisioningstatus.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimagestatusprovisioningstatus.go new file mode 100644 index 00000000000..9ddfb9caf2c --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimagestatusprovisioningstatus.go @@ -0,0 +1,9 @@ +package marketplacegalleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceGalleryImageStatusProvisioningStatus struct { + OperationId *string `json:"operationId,omitempty"` + Status *Status `json:"status,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimagesupdaterequest.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimagesupdaterequest.go new file mode 100644 index 00000000000..6639391a1a6 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/model_marketplacegalleryimagesupdaterequest.go @@ -0,0 +1,8 @@ +package marketplacegalleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceGalleryImagesUpdateRequest struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/predicates.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/predicates.go new file mode 100644 index 00000000000..5d612f67073 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/predicates.go @@ -0,0 +1,32 @@ +package marketplacegalleryimages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceGalleryImagesOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p MarketplaceGalleryImagesOperationPredicate) Matches(input MarketplaceGalleryImages) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/version.go b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/version.go new file mode 100644 index 00000000000..44f2cd2385e --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/marketplacegalleryimages/version.go @@ -0,0 +1,12 @@ +package marketplacegalleryimages + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/marketplacegalleryimages/%s", defaultApiVersion) +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/README.md b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/README.md new file mode 100644 index 00000000000..4054314e3fe --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces` Documentation + +The `networkinterfaces` SDK allows for interaction with the Azure Resource Manager Service `azurestackhci` (API Version `2023-09-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces" +``` + + +### Client Initialization + +```go +client := networkinterfaces.NewNetworkInterfacesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkInterfacesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := networkinterfaces.NewNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceValue") + +payload := networkinterfaces.NetworkInterfaces{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkInterfacesClient.Delete` + +```go +ctx := context.TODO() +id := networkinterfaces.NewNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkInterfacesClient.Get` + +```go +ctx := context.TODO() +id := networkinterfaces.NewNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkInterfacesClient.List` + +```go +ctx := context.TODO() +id := networkinterfaces.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkInterfacesClient.ListAll` + +```go +ctx := context.TODO() +id := networkinterfaces.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkInterfacesClient.Update` + +```go +ctx := context.TODO() +id := networkinterfaces.NewNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceValue") + +payload := networkinterfaces.NetworkInterfacesUpdateRequest{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/client.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/client.go new file mode 100644 index 00000000000..cd098aeccdf --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/client.go @@ -0,0 +1,26 @@ +package networkinterfaces + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacesClient struct { + Client *resourcemanager.Client +} + +func NewNetworkInterfacesClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkInterfacesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "networkinterfaces", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkInterfacesClient: %+v", err) + } + + return &NetworkInterfacesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/constants.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/constants.go new file mode 100644 index 00000000000..ade27d81ffc --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/constants.go @@ -0,0 +1,145 @@ +package networkinterfaces + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocationTypes string + +const ( + ExtendedLocationTypesCustomLocation ExtendedLocationTypes = "CustomLocation" +) + +func PossibleValuesForExtendedLocationTypes() []string { + return []string{ + string(ExtendedLocationTypesCustomLocation), + } +} + +func (s *ExtendedLocationTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExtendedLocationTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExtendedLocationTypes(input string) (*ExtendedLocationTypes, error) { + vals := map[string]ExtendedLocationTypes{ + "customlocation": ExtendedLocationTypesCustomLocation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExtendedLocationTypes(input) + return &out, nil +} + +type ProvisioningStateEnum string + +const ( + ProvisioningStateEnumAccepted ProvisioningStateEnum = "Accepted" + ProvisioningStateEnumCanceled ProvisioningStateEnum = "Canceled" + ProvisioningStateEnumDeleting ProvisioningStateEnum = "Deleting" + ProvisioningStateEnumFailed ProvisioningStateEnum = "Failed" + ProvisioningStateEnumInProgress ProvisioningStateEnum = "InProgress" + ProvisioningStateEnumSucceeded ProvisioningStateEnum = "Succeeded" +) + +func PossibleValuesForProvisioningStateEnum() []string { + return []string{ + string(ProvisioningStateEnumAccepted), + string(ProvisioningStateEnumCanceled), + string(ProvisioningStateEnumDeleting), + string(ProvisioningStateEnumFailed), + string(ProvisioningStateEnumInProgress), + string(ProvisioningStateEnumSucceeded), + } +} + +func (s *ProvisioningStateEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningStateEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningStateEnum(input string) (*ProvisioningStateEnum, error) { + vals := map[string]ProvisioningStateEnum{ + "accepted": ProvisioningStateEnumAccepted, + "canceled": ProvisioningStateEnumCanceled, + "deleting": ProvisioningStateEnumDeleting, + "failed": ProvisioningStateEnumFailed, + "inprogress": ProvisioningStateEnumInProgress, + "succeeded": ProvisioningStateEnumSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningStateEnum(input) + return &out, nil +} + +type Status string + +const ( + StatusFailed Status = "Failed" + StatusInProgress Status = "InProgress" + StatusSucceeded Status = "Succeeded" +) + +func PossibleValuesForStatus() []string { + return []string{ + string(StatusFailed), + string(StatusInProgress), + string(StatusSucceeded), + } +} + +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatus(input string) (*Status, error) { + vals := map[string]Status{ + "failed": StatusFailed, + "inprogress": StatusInProgress, + "succeeded": StatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Status(input) + return &out, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/id_networkinterface.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/id_networkinterface.go new file mode 100644 index 00000000000..16a79019e00 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/id_networkinterface.go @@ -0,0 +1,125 @@ +package networkinterfaces + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkInterfaceId{} + +// NetworkInterfaceId is a struct representing the Resource ID for a Network Interface +type NetworkInterfaceId struct { + SubscriptionId string + ResourceGroupName string + NetworkInterfaceName string +} + +// NewNetworkInterfaceID returns a new NetworkInterfaceId struct +func NewNetworkInterfaceID(subscriptionId string, resourceGroupName string, networkInterfaceName string) NetworkInterfaceId { + return NetworkInterfaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkInterfaceName: networkInterfaceName, + } +} + +// ParseNetworkInterfaceID parses 'input' into a NetworkInterfaceId +func ParseNetworkInterfaceID(input string) (*NetworkInterfaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkInterfaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkInterfaceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkInterfaceIDInsensitively parses 'input' case-insensitively into a NetworkInterfaceId +// note: this method should only be used for API response data and not user input +func ParseNetworkInterfaceIDInsensitively(input string) (*NetworkInterfaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkInterfaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkInterfaceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkInterfaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkInterfaceName, ok = input.Parsed["networkInterfaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkInterfaceName", input) + } + + return nil +} + +// ValidateNetworkInterfaceID checks that 'input' can be parsed as a Network Interface ID +func ValidateNetworkInterfaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkInterfaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Interface ID +func (id NetworkInterfaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AzureStackHCI/networkInterfaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkInterfaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Interface ID +func (id NetworkInterfaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAzureStackHCI", "Microsoft.AzureStackHCI", "Microsoft.AzureStackHCI"), + resourceids.StaticSegment("staticNetworkInterfaces", "networkInterfaces", "networkInterfaces"), + resourceids.UserSpecifiedSegment("networkInterfaceName", "networkInterfaceValue"), + } +} + +// String returns a human-readable description of this Network Interface ID +func (id NetworkInterfaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Interface Name: %q", id.NetworkInterfaceName), + } + return fmt.Sprintf("Network Interface (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/id_networkinterface_test.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/id_networkinterface_test.go new file mode 100644 index 00000000000..a37ca6e894b --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/id_networkinterface_test.go @@ -0,0 +1,282 @@ +package networkinterfaces + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkInterfaceId{} + +func TestNewNetworkInterfaceID(t *testing.T) { + id := NewNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkInterfaceName != "networkInterfaceValue" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkInterfaceName'", id.NetworkInterfaceName, "networkInterfaceValue") + } +} + +func TestFormatNetworkInterfaceID(t *testing.T) { + actual := NewNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/networkInterfaces/networkInterfaceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkInterfaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkInterfaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/networkInterfaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/networkInterfaces/networkInterfaceValue", + Expected: &NetworkInterfaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkInterfaceName: "networkInterfaceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/networkInterfaces/networkInterfaceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkInterfaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkInterfaceName != v.Expected.NetworkInterfaceName { + t.Fatalf("Expected %q but got %q for NetworkInterfaceName", v.Expected.NetworkInterfaceName, actual.NetworkInterfaceName) + } + + } +} + +func TestParseNetworkInterfaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkInterfaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/networkInterfaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/nEtWoRkInTeRfAcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/networkInterfaces/networkInterfaceValue", + Expected: &NetworkInterfaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkInterfaceName: "networkInterfaceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/networkInterfaces/networkInterfaceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/nEtWoRkInTeRfAcEs/nEtWoRkInTeRfAcEvAlUe", + Expected: &NetworkInterfaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkInterfaceName: "nEtWoRkInTeRfAcEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/nEtWoRkInTeRfAcEs/nEtWoRkInTeRfAcEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkInterfaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkInterfaceName != v.Expected.NetworkInterfaceName { + t.Fatalf("Expected %q but got %q for NetworkInterfaceName", v.Expected.NetworkInterfaceName, actual.NetworkInterfaceName) + } + + } +} + +func TestSegmentsForNetworkInterfaceId(t *testing.T) { + segments := NetworkInterfaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkInterfaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_createorupdate.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_createorupdate.go new file mode 100644 index 00000000000..cd8f1922203 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_createorupdate.go @@ -0,0 +1,74 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdate ... +func (c NetworkInterfacesClient) CreateOrUpdate(ctx context.Context, id NetworkInterfaceId, input NetworkInterfaces) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c NetworkInterfacesClient) CreateOrUpdateThenPoll(ctx context.Context, id NetworkInterfaceId, input NetworkInterfaces) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_delete.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_delete.go new file mode 100644 index 00000000000..7b815712bf2 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_delete.go @@ -0,0 +1,70 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c NetworkInterfacesClient) Delete(ctx context.Context, id NetworkInterfaceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c NetworkInterfacesClient) DeleteThenPoll(ctx context.Context, id NetworkInterfaceId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_get.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_get.go new file mode 100644 index 00000000000..90cc6d34bb5 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_get.go @@ -0,0 +1,51 @@ +package networkinterfaces + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkInterfaces +} + +// Get ... +func (c NetworkInterfacesClient) Get(ctx context.Context, id NetworkInterfaceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_list.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_list.go new file mode 100644 index 00000000000..f9bc06e5631 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_list.go @@ -0,0 +1,92 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkInterfaces +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkInterfaces +} + +// List ... +func (c NetworkInterfacesClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/networkInterfaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkInterfaces `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NetworkInterfacesClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, NetworkInterfacesOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkInterfacesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate NetworkInterfacesOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NetworkInterfaces, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_listall.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_listall.go new file mode 100644 index 00000000000..26c2889a8f2 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_listall.go @@ -0,0 +1,92 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkInterfaces +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkInterfaces +} + +// ListAll ... +func (c NetworkInterfacesClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/networkInterfaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkInterfaces `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c NetworkInterfacesClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, NetworkInterfacesOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkInterfacesClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate NetworkInterfacesOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]NetworkInterfaces, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_update.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_update.go new file mode 100644 index 00000000000..7daf492b51f --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/method_update.go @@ -0,0 +1,74 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c NetworkInterfacesClient) Update(ctx context.Context, id NetworkInterfaceId, input NetworkInterfacesUpdateRequest) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c NetworkInterfacesClient) UpdateThenPoll(ctx context.Context, id NetworkInterfaceId, input NetworkInterfacesUpdateRequest) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_extendedlocation.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_extendedlocation.go new file mode 100644 index 00000000000..b2fc7d38b2d --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_extendedlocation.go @@ -0,0 +1,9 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *ExtendedLocationTypes `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_interfacednssettings.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_interfacednssettings.go new file mode 100644 index 00000000000..cb2f42c0967 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_interfacednssettings.go @@ -0,0 +1,8 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InterfaceDNSSettings struct { + DnsServers *[]string `json:"dnsServers,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_ipconfiguration.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_ipconfiguration.go new file mode 100644 index 00000000000..4dba57abec2 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_ipconfiguration.go @@ -0,0 +1,9 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_ipconfigurationproperties.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_ipconfigurationproperties.go new file mode 100644 index 00000000000..9a6acce3482 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_ipconfigurationproperties.go @@ -0,0 +1,11 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProperties struct { + Gateway *string `json:"gateway,omitempty"` + PrefixLength *string `json:"prefixLength,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + Subnet *IPConfigurationPropertiesSubnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_ipconfigurationpropertiessubnet.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_ipconfigurationpropertiessubnet.go new file mode 100644 index 00000000000..b87520c7872 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_ipconfigurationpropertiessubnet.go @@ -0,0 +1,8 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesSubnet struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_networkinterfaceproperties.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_networkinterfaceproperties.go new file mode 100644 index 00000000000..c39cb163aad --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_networkinterfaceproperties.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceProperties struct { + DnsSettings *InterfaceDNSSettings `json:"dnsSettings,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + ProvisioningState *ProvisioningStateEnum `json:"provisioningState,omitempty"` + Status *NetworkInterfaceStatus `json:"status,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_networkinterfaces.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_networkinterfaces.go new file mode 100644 index 00000000000..5c01ce90c80 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_networkinterfaces.go @@ -0,0 +1,19 @@ +package networkinterfaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaces struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_networkinterfacestatus.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_networkinterfacestatus.go new file mode 100644 index 00000000000..eace96b9616 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_networkinterfacestatus.go @@ -0,0 +1,10 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceStatus struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ProvisioningStatus *NetworkInterfaceStatusProvisioningStatus `json:"provisioningStatus,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_networkinterfacestatusprovisioningstatus.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_networkinterfacestatusprovisioningstatus.go new file mode 100644 index 00000000000..37d22bd02a5 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_networkinterfacestatusprovisioningstatus.go @@ -0,0 +1,9 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceStatusProvisioningStatus struct { + OperationId *string `json:"operationId,omitempty"` + Status *Status `json:"status,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_networkinterfacesupdaterequest.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_networkinterfacesupdaterequest.go new file mode 100644 index 00000000000..f6cb091d079 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/model_networkinterfacesupdaterequest.go @@ -0,0 +1,8 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacesUpdateRequest struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/predicates.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/predicates.go new file mode 100644 index 00000000000..9e8cac5d9c5 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/predicates.go @@ -0,0 +1,32 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacesOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p NetworkInterfacesOperationPredicate) Matches(input NetworkInterfaces) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/version.go b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/version.go new file mode 100644 index 00000000000..d316b816337 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/networkinterfaces/version.go @@ -0,0 +1,12 @@ +package networkinterfaces + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/networkinterfaces/%s", defaultApiVersion) +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/README.md b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/README.md new file mode 100644 index 00000000000..e89035a1741 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers` Documentation + +The `storagecontainers` SDK allows for interaction with the Azure Resource Manager Service `azurestackhci` (API Version `2023-09-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers" +``` + + +### Client Initialization + +```go +client := storagecontainers.NewStorageContainersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `StorageContainersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := storagecontainers.NewStorageContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageContainerValue") + +payload := storagecontainers.StorageContainers{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StorageContainersClient.Delete` + +```go +ctx := context.TODO() +id := storagecontainers.NewStorageContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageContainerValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StorageContainersClient.Get` + +```go +ctx := context.TODO() +id := storagecontainers.NewStorageContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageContainerValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StorageContainersClient.List` + +```go +ctx := context.TODO() +id := storagecontainers.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StorageContainersClient.ListAll` + +```go +ctx := context.TODO() +id := storagecontainers.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StorageContainersClient.Update` + +```go +ctx := context.TODO() +id := storagecontainers.NewStorageContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageContainerValue") + +payload := storagecontainers.StorageContainersUpdateRequest{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/client.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/client.go new file mode 100644 index 00000000000..db251da0046 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/client.go @@ -0,0 +1,26 @@ +package storagecontainers + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageContainersClient struct { + Client *resourcemanager.Client +} + +func NewStorageContainersClientWithBaseURI(sdkApi sdkEnv.Api) (*StorageContainersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "storagecontainers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating StorageContainersClient: %+v", err) + } + + return &StorageContainersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/constants.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/constants.go new file mode 100644 index 00000000000..eeeeb0bb775 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/constants.go @@ -0,0 +1,145 @@ +package storagecontainers + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocationTypes string + +const ( + ExtendedLocationTypesCustomLocation ExtendedLocationTypes = "CustomLocation" +) + +func PossibleValuesForExtendedLocationTypes() []string { + return []string{ + string(ExtendedLocationTypesCustomLocation), + } +} + +func (s *ExtendedLocationTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExtendedLocationTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExtendedLocationTypes(input string) (*ExtendedLocationTypes, error) { + vals := map[string]ExtendedLocationTypes{ + "customlocation": ExtendedLocationTypesCustomLocation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExtendedLocationTypes(input) + return &out, nil +} + +type ProvisioningStateEnum string + +const ( + ProvisioningStateEnumAccepted ProvisioningStateEnum = "Accepted" + ProvisioningStateEnumCanceled ProvisioningStateEnum = "Canceled" + ProvisioningStateEnumDeleting ProvisioningStateEnum = "Deleting" + ProvisioningStateEnumFailed ProvisioningStateEnum = "Failed" + ProvisioningStateEnumInProgress ProvisioningStateEnum = "InProgress" + ProvisioningStateEnumSucceeded ProvisioningStateEnum = "Succeeded" +) + +func PossibleValuesForProvisioningStateEnum() []string { + return []string{ + string(ProvisioningStateEnumAccepted), + string(ProvisioningStateEnumCanceled), + string(ProvisioningStateEnumDeleting), + string(ProvisioningStateEnumFailed), + string(ProvisioningStateEnumInProgress), + string(ProvisioningStateEnumSucceeded), + } +} + +func (s *ProvisioningStateEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningStateEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningStateEnum(input string) (*ProvisioningStateEnum, error) { + vals := map[string]ProvisioningStateEnum{ + "accepted": ProvisioningStateEnumAccepted, + "canceled": ProvisioningStateEnumCanceled, + "deleting": ProvisioningStateEnumDeleting, + "failed": ProvisioningStateEnumFailed, + "inprogress": ProvisioningStateEnumInProgress, + "succeeded": ProvisioningStateEnumSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningStateEnum(input) + return &out, nil +} + +type Status string + +const ( + StatusFailed Status = "Failed" + StatusInProgress Status = "InProgress" + StatusSucceeded Status = "Succeeded" +) + +func PossibleValuesForStatus() []string { + return []string{ + string(StatusFailed), + string(StatusInProgress), + string(StatusSucceeded), + } +} + +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatus(input string) (*Status, error) { + vals := map[string]Status{ + "failed": StatusFailed, + "inprogress": StatusInProgress, + "succeeded": StatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Status(input) + return &out, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/id_storagecontainer.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/id_storagecontainer.go new file mode 100644 index 00000000000..20284ffcabd --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/id_storagecontainer.go @@ -0,0 +1,125 @@ +package storagecontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &StorageContainerId{} + +// StorageContainerId is a struct representing the Resource ID for a Storage Container +type StorageContainerId struct { + SubscriptionId string + ResourceGroupName string + StorageContainerName string +} + +// NewStorageContainerID returns a new StorageContainerId struct +func NewStorageContainerID(subscriptionId string, resourceGroupName string, storageContainerName string) StorageContainerId { + return StorageContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StorageContainerName: storageContainerName, + } +} + +// ParseStorageContainerID parses 'input' into a StorageContainerId +func ParseStorageContainerID(input string) (*StorageContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&StorageContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StorageContainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStorageContainerIDInsensitively parses 'input' case-insensitively into a StorageContainerId +// note: this method should only be used for API response data and not user input +func ParseStorageContainerIDInsensitively(input string) (*StorageContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&StorageContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StorageContainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StorageContainerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StorageContainerName, ok = input.Parsed["storageContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "storageContainerName", input) + } + + return nil +} + +// ValidateStorageContainerID checks that 'input' can be parsed as a Storage Container ID +func ValidateStorageContainerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseStorageContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Storage Container ID +func (id StorageContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AzureStackHCI/storageContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StorageContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Storage Container ID +func (id StorageContainerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAzureStackHCI", "Microsoft.AzureStackHCI", "Microsoft.AzureStackHCI"), + resourceids.StaticSegment("staticStorageContainers", "storageContainers", "storageContainers"), + resourceids.UserSpecifiedSegment("storageContainerName", "storageContainerValue"), + } +} + +// String returns a human-readable description of this Storage Container ID +func (id StorageContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Storage Container Name: %q", id.StorageContainerName), + } + return fmt.Sprintf("Storage Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/id_storagecontainer_test.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/id_storagecontainer_test.go new file mode 100644 index 00000000000..72d31dfd4ea --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/id_storagecontainer_test.go @@ -0,0 +1,282 @@ +package storagecontainers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &StorageContainerId{} + +func TestNewStorageContainerID(t *testing.T) { + id := NewStorageContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageContainerValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.StorageContainerName != "storageContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'StorageContainerName'", id.StorageContainerName, "storageContainerValue") + } +} + +func TestFormatStorageContainerID(t *testing.T) { + actual := NewStorageContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "storageContainerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/storageContainers/storageContainerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStorageContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StorageContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/storageContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/storageContainers/storageContainerValue", + Expected: &StorageContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StorageContainerName: "storageContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/storageContainers/storageContainerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStorageContainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StorageContainerName != v.Expected.StorageContainerName { + t.Fatalf("Expected %q but got %q for StorageContainerName", v.Expected.StorageContainerName, actual.StorageContainerName) + } + + } +} + +func TestParseStorageContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StorageContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/storageContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/sToRaGeCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/storageContainers/storageContainerValue", + Expected: &StorageContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StorageContainerName: "storageContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/storageContainers/storageContainerValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/sToRaGeCoNtAiNeRs/sToRaGeCoNtAiNeRvAlUe", + Expected: &StorageContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StorageContainerName: "sToRaGeCoNtAiNeRvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/sToRaGeCoNtAiNeRs/sToRaGeCoNtAiNeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStorageContainerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StorageContainerName != v.Expected.StorageContainerName { + t.Fatalf("Expected %q but got %q for StorageContainerName", v.Expected.StorageContainerName, actual.StorageContainerName) + } + + } +} + +func TestSegmentsForStorageContainerId(t *testing.T) { + segments := StorageContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StorageContainerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_createorupdate.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_createorupdate.go new file mode 100644 index 00000000000..410bd8d9daa --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_createorupdate.go @@ -0,0 +1,74 @@ +package storagecontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdate ... +func (c StorageContainersClient) CreateOrUpdate(ctx context.Context, id StorageContainerId, input StorageContainers) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c StorageContainersClient) CreateOrUpdateThenPoll(ctx context.Context, id StorageContainerId, input StorageContainers) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_delete.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_delete.go new file mode 100644 index 00000000000..4c2f5715cf4 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_delete.go @@ -0,0 +1,70 @@ +package storagecontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c StorageContainersClient) Delete(ctx context.Context, id StorageContainerId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c StorageContainersClient) DeleteThenPoll(ctx context.Context, id StorageContainerId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_get.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_get.go new file mode 100644 index 00000000000..099aa7022a3 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_get.go @@ -0,0 +1,51 @@ +package storagecontainers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StorageContainers +} + +// Get ... +func (c StorageContainersClient) Get(ctx context.Context, id StorageContainerId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_list.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_list.go new file mode 100644 index 00000000000..6c64a2ba76f --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_list.go @@ -0,0 +1,92 @@ +package storagecontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StorageContainers +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageContainers +} + +// List ... +func (c StorageContainersClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/storageContainers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StorageContainers `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c StorageContainersClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, StorageContainersOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StorageContainersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate StorageContainersOperationPredicate) (result ListCompleteResult, err error) { + items := make([]StorageContainers, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_listall.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_listall.go new file mode 100644 index 00000000000..c924bd0169d --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_listall.go @@ -0,0 +1,92 @@ +package storagecontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StorageContainers +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageContainers +} + +// ListAll ... +func (c StorageContainersClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/storageContainers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StorageContainers `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c StorageContainersClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, StorageContainersOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StorageContainersClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate StorageContainersOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]StorageContainers, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_update.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_update.go new file mode 100644 index 00000000000..4f6f59b6c4c --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/method_update.go @@ -0,0 +1,74 @@ +package storagecontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c StorageContainersClient) Update(ctx context.Context, id StorageContainerId, input StorageContainersUpdateRequest) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c StorageContainersClient) UpdateThenPoll(ctx context.Context, id StorageContainerId, input StorageContainersUpdateRequest) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_extendedlocation.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_extendedlocation.go new file mode 100644 index 00000000000..e1936c7961a --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_extendedlocation.go @@ -0,0 +1,9 @@ +package storagecontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *ExtendedLocationTypes `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_storagecontainerproperties.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_storagecontainerproperties.go new file mode 100644 index 00000000000..6cdde28e1f2 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_storagecontainerproperties.go @@ -0,0 +1,10 @@ +package storagecontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageContainerProperties struct { + Path string `json:"path"` + ProvisioningState *ProvisioningStateEnum `json:"provisioningState,omitempty"` + Status *StorageContainerStatus `json:"status,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_storagecontainers.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_storagecontainers.go new file mode 100644 index 00000000000..f669724072d --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_storagecontainers.go @@ -0,0 +1,19 @@ +package storagecontainers + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageContainers struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *StorageContainerProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_storagecontainerstatus.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_storagecontainerstatus.go new file mode 100644 index 00000000000..f4ee8603c33 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_storagecontainerstatus.go @@ -0,0 +1,12 @@ +package storagecontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageContainerStatus struct { + AvailableSizeMB *int64 `json:"availableSizeMB,omitempty"` + ContainerSizeMB *int64 `json:"containerSizeMB,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ProvisioningStatus *StorageContainerStatusProvisioningStatus `json:"provisioningStatus,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_storagecontainerstatusprovisioningstatus.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_storagecontainerstatusprovisioningstatus.go new file mode 100644 index 00000000000..ae2e6ebaff8 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_storagecontainerstatusprovisioningstatus.go @@ -0,0 +1,9 @@ +package storagecontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageContainerStatusProvisioningStatus struct { + OperationId *string `json:"operationId,omitempty"` + Status *Status `json:"status,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_storagecontainersupdaterequest.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_storagecontainersupdaterequest.go new file mode 100644 index 00000000000..f7961c17b3c --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/model_storagecontainersupdaterequest.go @@ -0,0 +1,8 @@ +package storagecontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageContainersUpdateRequest struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/predicates.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/predicates.go new file mode 100644 index 00000000000..0ca6fa52190 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/predicates.go @@ -0,0 +1,32 @@ +package storagecontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageContainersOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p StorageContainersOperationPredicate) Matches(input StorageContainers) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/version.go b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/version.go new file mode 100644 index 00000000000..83dbdaf7dd4 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/storagecontainers/version.go @@ -0,0 +1,12 @@ +package storagecontainers + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/storagecontainers/%s", defaultApiVersion) +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/README.md b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/README.md new file mode 100644 index 00000000000..2989881c563 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks` Documentation + +The `virtualharddisks` SDK allows for interaction with the Azure Resource Manager Service `azurestackhci` (API Version `2023-09-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks" +``` + + +### Client Initialization + +```go +client := virtualharddisks.NewVirtualHardDisksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VirtualHardDisksClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualharddisks.NewVirtualHardDiskID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHardDiskValue") + +payload := virtualharddisks.VirtualHardDisks{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualHardDisksClient.Delete` + +```go +ctx := context.TODO() +id := virtualharddisks.NewVirtualHardDiskID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHardDiskValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualHardDisksClient.Get` + +```go +ctx := context.TODO() +id := virtualharddisks.NewVirtualHardDiskID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHardDiskValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualHardDisksClient.List` + +```go +ctx := context.TODO() +id := virtualharddisks.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualHardDisksClient.ListAll` + +```go +ctx := context.TODO() +id := virtualharddisks.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualHardDisksClient.Update` + +```go +ctx := context.TODO() +id := virtualharddisks.NewVirtualHardDiskID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHardDiskValue") + +payload := virtualharddisks.VirtualHardDisksUpdateRequest{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/client.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/client.go new file mode 100644 index 00000000000..337d4efa659 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/client.go @@ -0,0 +1,26 @@ +package virtualharddisks + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHardDisksClient struct { + Client *resourcemanager.Client +} + +func NewVirtualHardDisksClientWithBaseURI(sdkApi sdkEnv.Api) (*VirtualHardDisksClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "virtualharddisks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VirtualHardDisksClient: %+v", err) + } + + return &VirtualHardDisksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/constants.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/constants.go new file mode 100644 index 00000000000..6387b527b49 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/constants.go @@ -0,0 +1,227 @@ +package virtualharddisks + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskFileFormat string + +const ( + DiskFileFormatVhd DiskFileFormat = "vhd" + DiskFileFormatVhdx DiskFileFormat = "vhdx" +) + +func PossibleValuesForDiskFileFormat() []string { + return []string{ + string(DiskFileFormatVhd), + string(DiskFileFormatVhdx), + } +} + +func (s *DiskFileFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskFileFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskFileFormat(input string) (*DiskFileFormat, error) { + vals := map[string]DiskFileFormat{ + "vhd": DiskFileFormatVhd, + "vhdx": DiskFileFormatVhdx, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskFileFormat(input) + return &out, nil +} + +type ExtendedLocationTypes string + +const ( + ExtendedLocationTypesCustomLocation ExtendedLocationTypes = "CustomLocation" +) + +func PossibleValuesForExtendedLocationTypes() []string { + return []string{ + string(ExtendedLocationTypesCustomLocation), + } +} + +func (s *ExtendedLocationTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExtendedLocationTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExtendedLocationTypes(input string) (*ExtendedLocationTypes, error) { + vals := map[string]ExtendedLocationTypes{ + "customlocation": ExtendedLocationTypesCustomLocation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExtendedLocationTypes(input) + return &out, nil +} + +type HyperVGeneration string + +const ( + HyperVGenerationVOne HyperVGeneration = "V1" + HyperVGenerationVTwo HyperVGeneration = "V2" +) + +func PossibleValuesForHyperVGeneration() []string { + return []string{ + string(HyperVGenerationVOne), + string(HyperVGenerationVTwo), + } +} + +func (s *HyperVGeneration) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHyperVGeneration(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHyperVGeneration(input string) (*HyperVGeneration, error) { + vals := map[string]HyperVGeneration{ + "v1": HyperVGenerationVOne, + "v2": HyperVGenerationVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HyperVGeneration(input) + return &out, nil +} + +type ProvisioningStateEnum string + +const ( + ProvisioningStateEnumAccepted ProvisioningStateEnum = "Accepted" + ProvisioningStateEnumCanceled ProvisioningStateEnum = "Canceled" + ProvisioningStateEnumDeleting ProvisioningStateEnum = "Deleting" + ProvisioningStateEnumFailed ProvisioningStateEnum = "Failed" + ProvisioningStateEnumInProgress ProvisioningStateEnum = "InProgress" + ProvisioningStateEnumSucceeded ProvisioningStateEnum = "Succeeded" +) + +func PossibleValuesForProvisioningStateEnum() []string { + return []string{ + string(ProvisioningStateEnumAccepted), + string(ProvisioningStateEnumCanceled), + string(ProvisioningStateEnumDeleting), + string(ProvisioningStateEnumFailed), + string(ProvisioningStateEnumInProgress), + string(ProvisioningStateEnumSucceeded), + } +} + +func (s *ProvisioningStateEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningStateEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningStateEnum(input string) (*ProvisioningStateEnum, error) { + vals := map[string]ProvisioningStateEnum{ + "accepted": ProvisioningStateEnumAccepted, + "canceled": ProvisioningStateEnumCanceled, + "deleting": ProvisioningStateEnumDeleting, + "failed": ProvisioningStateEnumFailed, + "inprogress": ProvisioningStateEnumInProgress, + "succeeded": ProvisioningStateEnumSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningStateEnum(input) + return &out, nil +} + +type Status string + +const ( + StatusFailed Status = "Failed" + StatusInProgress Status = "InProgress" + StatusSucceeded Status = "Succeeded" +) + +func PossibleValuesForStatus() []string { + return []string{ + string(StatusFailed), + string(StatusInProgress), + string(StatusSucceeded), + } +} + +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatus(input string) (*Status, error) { + vals := map[string]Status{ + "failed": StatusFailed, + "inprogress": StatusInProgress, + "succeeded": StatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Status(input) + return &out, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/id_virtualharddisk.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/id_virtualharddisk.go new file mode 100644 index 00000000000..db4eb3fb44c --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/id_virtualharddisk.go @@ -0,0 +1,125 @@ +package virtualharddisks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualHardDiskId{} + +// VirtualHardDiskId is a struct representing the Resource ID for a Virtual Hard Disk +type VirtualHardDiskId struct { + SubscriptionId string + ResourceGroupName string + VirtualHardDiskName string +} + +// NewVirtualHardDiskID returns a new VirtualHardDiskId struct +func NewVirtualHardDiskID(subscriptionId string, resourceGroupName string, virtualHardDiskName string) VirtualHardDiskId { + return VirtualHardDiskId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualHardDiskName: virtualHardDiskName, + } +} + +// ParseVirtualHardDiskID parses 'input' into a VirtualHardDiskId +func ParseVirtualHardDiskID(input string) (*VirtualHardDiskId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualHardDiskId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualHardDiskId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualHardDiskIDInsensitively parses 'input' case-insensitively into a VirtualHardDiskId +// note: this method should only be used for API response data and not user input +func ParseVirtualHardDiskIDInsensitively(input string) (*VirtualHardDiskId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualHardDiskId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualHardDiskId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualHardDiskId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VirtualHardDiskName, ok = input.Parsed["virtualHardDiskName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualHardDiskName", input) + } + + return nil +} + +// ValidateVirtualHardDiskID checks that 'input' can be parsed as a Virtual Hard Disk ID +func ValidateVirtualHardDiskID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVirtualHardDiskID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Hard Disk ID +func (id VirtualHardDiskId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.AzureStackHCI/virtualHardDisks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualHardDiskName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Hard Disk ID +func (id VirtualHardDiskId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAzureStackHCI", "Microsoft.AzureStackHCI", "Microsoft.AzureStackHCI"), + resourceids.StaticSegment("staticVirtualHardDisks", "virtualHardDisks", "virtualHardDisks"), + resourceids.UserSpecifiedSegment("virtualHardDiskName", "virtualHardDiskValue"), + } +} + +// String returns a human-readable description of this Virtual Hard Disk ID +func (id VirtualHardDiskId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Hard Disk Name: %q", id.VirtualHardDiskName), + } + return fmt.Sprintf("Virtual Hard Disk (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/id_virtualharddisk_test.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/id_virtualharddisk_test.go new file mode 100644 index 00000000000..3ba0ea2c25b --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/id_virtualharddisk_test.go @@ -0,0 +1,282 @@ +package virtualharddisks + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualHardDiskId{} + +func TestNewVirtualHardDiskID(t *testing.T) { + id := NewVirtualHardDiskID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHardDiskValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VirtualHardDiskName != "virtualHardDiskValue" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualHardDiskName'", id.VirtualHardDiskName, "virtualHardDiskValue") + } +} + +func TestFormatVirtualHardDiskID(t *testing.T) { + actual := NewVirtualHardDiskID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHardDiskValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/virtualHardDisks/virtualHardDiskValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualHardDiskID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualHardDiskId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/virtualHardDisks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/virtualHardDisks/virtualHardDiskValue", + Expected: &VirtualHardDiskId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualHardDiskName: "virtualHardDiskValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/virtualHardDisks/virtualHardDiskValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualHardDiskID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualHardDiskName != v.Expected.VirtualHardDiskName { + t.Fatalf("Expected %q but got %q for VirtualHardDiskName", v.Expected.VirtualHardDiskName, actual.VirtualHardDiskName) + } + + } +} + +func TestParseVirtualHardDiskIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualHardDiskId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/virtualHardDisks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/vIrTuAlHaRdDiSkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/virtualHardDisks/virtualHardDiskValue", + Expected: &VirtualHardDiskId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualHardDiskName: "virtualHardDiskValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.AzureStackHCI/virtualHardDisks/virtualHardDiskValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/vIrTuAlHaRdDiSkS/vIrTuAlHaRdDiSkVaLuE", + Expected: &VirtualHardDiskId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualHardDiskName: "vIrTuAlHaRdDiSkVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aZuReStAcKhCi/vIrTuAlHaRdDiSkS/vIrTuAlHaRdDiSkVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualHardDiskIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualHardDiskName != v.Expected.VirtualHardDiskName { + t.Fatalf("Expected %q but got %q for VirtualHardDiskName", v.Expected.VirtualHardDiskName, actual.VirtualHardDiskName) + } + + } +} + +func TestSegmentsForVirtualHardDiskId(t *testing.T) { + segments := VirtualHardDiskId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualHardDiskId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_createorupdate.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_createorupdate.go new file mode 100644 index 00000000000..596efd65941 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_createorupdate.go @@ -0,0 +1,74 @@ +package virtualharddisks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdate ... +func (c VirtualHardDisksClient) CreateOrUpdate(ctx context.Context, id VirtualHardDiskId, input VirtualHardDisks) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c VirtualHardDisksClient) CreateOrUpdateThenPoll(ctx context.Context, id VirtualHardDiskId, input VirtualHardDisks) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_delete.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_delete.go new file mode 100644 index 00000000000..6abc2528822 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_delete.go @@ -0,0 +1,70 @@ +package virtualharddisks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c VirtualHardDisksClient) Delete(ctx context.Context, id VirtualHardDiskId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c VirtualHardDisksClient) DeleteThenPoll(ctx context.Context, id VirtualHardDiskId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_get.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_get.go new file mode 100644 index 00000000000..bc2f450b7df --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_get.go @@ -0,0 +1,51 @@ +package virtualharddisks + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualHardDisks +} + +// Get ... +func (c VirtualHardDisksClient) Get(ctx context.Context, id VirtualHardDiskId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_list.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_list.go new file mode 100644 index 00000000000..4988494c02e --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_list.go @@ -0,0 +1,92 @@ +package virtualharddisks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualHardDisks +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualHardDisks +} + +// List ... +func (c VirtualHardDisksClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/virtualHardDisks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualHardDisks `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c VirtualHardDisksClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, VirtualHardDisksOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualHardDisksClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate VirtualHardDisksOperationPredicate) (result ListCompleteResult, err error) { + items := make([]VirtualHardDisks, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_listall.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_listall.go new file mode 100644 index 00000000000..e8b12a2784d --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_listall.go @@ -0,0 +1,92 @@ +package virtualharddisks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualHardDisks +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualHardDisks +} + +// ListAll ... +func (c VirtualHardDisksClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/virtualHardDisks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualHardDisks `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c VirtualHardDisksClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, VirtualHardDisksOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualHardDisksClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate VirtualHardDisksOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]VirtualHardDisks, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_update.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_update.go new file mode 100644 index 00000000000..a57b270df93 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/method_update.go @@ -0,0 +1,74 @@ +package virtualharddisks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c VirtualHardDisksClient) Update(ctx context.Context, id VirtualHardDiskId, input VirtualHardDisksUpdateRequest) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c VirtualHardDisksClient) UpdateThenPoll(ctx context.Context, id VirtualHardDiskId, input VirtualHardDisksUpdateRequest) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_extendedlocation.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_extendedlocation.go new file mode 100644 index 00000000000..1769d210ca7 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_extendedlocation.go @@ -0,0 +1,9 @@ +package virtualharddisks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *ExtendedLocationTypes `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_virtualharddiskproperties.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_virtualharddiskproperties.go new file mode 100644 index 00000000000..94361608585 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_virtualharddiskproperties.go @@ -0,0 +1,17 @@ +package virtualharddisks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHardDiskProperties struct { + BlockSizeBytes *int64 `json:"blockSizeBytes,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + DiskFileFormat *DiskFileFormat `json:"diskFileFormat,omitempty"` + DiskSizeGB *int64 `json:"diskSizeGB,omitempty"` + Dynamic *bool `json:"dynamic,omitempty"` + HyperVGeneration *HyperVGeneration `json:"hyperVGeneration,omitempty"` + LogicalSectorBytes *int64 `json:"logicalSectorBytes,omitempty"` + PhysicalSectorBytes *int64 `json:"physicalSectorBytes,omitempty"` + ProvisioningState *ProvisioningStateEnum `json:"provisioningState,omitempty"` + Status *VirtualHardDiskStatus `json:"status,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_virtualharddisks.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_virtualharddisks.go new file mode 100644 index 00000000000..761800d5c3c --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_virtualharddisks.go @@ -0,0 +1,19 @@ +package virtualharddisks + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHardDisks struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *VirtualHardDiskProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_virtualharddiskstatus.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_virtualharddiskstatus.go new file mode 100644 index 00000000000..589b9607ee1 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_virtualharddiskstatus.go @@ -0,0 +1,10 @@ +package virtualharddisks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHardDiskStatus struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ProvisioningStatus *VirtualHardDiskStatusProvisioningStatus `json:"provisioningStatus,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_virtualharddiskstatusprovisioningstatus.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_virtualharddiskstatusprovisioningstatus.go new file mode 100644 index 00000000000..66fd03afc8b --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_virtualharddiskstatusprovisioningstatus.go @@ -0,0 +1,9 @@ +package virtualharddisks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHardDiskStatusProvisioningStatus struct { + OperationId *string `json:"operationId,omitempty"` + Status *Status `json:"status,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_virtualharddisksupdaterequest.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_virtualharddisksupdaterequest.go new file mode 100644 index 00000000000..1de25f7b8de --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/model_virtualharddisksupdaterequest.go @@ -0,0 +1,8 @@ +package virtualharddisks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHardDisksUpdateRequest struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/predicates.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/predicates.go new file mode 100644 index 00000000000..793ce512e65 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/predicates.go @@ -0,0 +1,32 @@ +package virtualharddisks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHardDisksOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p VirtualHardDisksOperationPredicate) Matches(input VirtualHardDisks) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/version.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/version.go new file mode 100644 index 00000000000..d907d3d025a --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualharddisks/version.go @@ -0,0 +1,12 @@ +package virtualharddisks + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/virtualharddisks/%s", defaultApiVersion) +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/README.md b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/README.md new file mode 100644 index 00000000000..5339fd02b60 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/README.md @@ -0,0 +1,135 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances` Documentation + +The `virtualmachineinstances` SDK allows for interaction with the Azure Resource Manager Service `azurestackhci` (API Version `2023-09-01-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances" +``` + + +### Client Initialization + +```go +client := virtualmachineinstances.NewVirtualMachineInstancesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VirtualMachineInstancesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualmachineinstances.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +payload := virtualmachineinstances.VirtualMachineInstance{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualMachineInstancesClient.Delete` + +```go +ctx := context.TODO() +id := virtualmachineinstances.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualMachineInstancesClient.Get` + +```go +ctx := context.TODO() +id := virtualmachineinstances.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualMachineInstancesClient.List` + +```go +ctx := context.TODO() +id := virtualmachineinstances.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualMachineInstancesClient.Restart` + +```go +ctx := context.TODO() +id := virtualmachineinstances.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +if err := client.RestartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualMachineInstancesClient.Start` + +```go +ctx := context.TODO() +id := virtualmachineinstances.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +if err := client.StartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualMachineInstancesClient.Stop` + +```go +ctx := context.TODO() +id := virtualmachineinstances.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +if err := client.StopThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualMachineInstancesClient.Update` + +```go +ctx := context.TODO() +id := virtualmachineinstances.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +payload := virtualmachineinstances.VirtualMachineInstanceUpdateRequest{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/client.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/client.go new file mode 100644 index 00000000000..e40ddc4adf5 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/client.go @@ -0,0 +1,26 @@ +package virtualmachineinstances + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstancesClient struct { + Client *resourcemanager.Client +} + +func NewVirtualMachineInstancesClientWithBaseURI(sdkApi sdkEnv.Api) (*VirtualMachineInstancesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "virtualmachineinstances", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VirtualMachineInstancesClient: %+v", err) + } + + return &VirtualMachineInstancesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/constants.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/constants.go new file mode 100644 index 00000000000..ecc73bd57b0 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/constants.go @@ -0,0 +1,475 @@ +package virtualmachineinstances + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocationTypes string + +const ( + ExtendedLocationTypesCustomLocation ExtendedLocationTypes = "CustomLocation" +) + +func PossibleValuesForExtendedLocationTypes() []string { + return []string{ + string(ExtendedLocationTypesCustomLocation), + } +} + +func (s *ExtendedLocationTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExtendedLocationTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExtendedLocationTypes(input string) (*ExtendedLocationTypes, error) { + vals := map[string]ExtendedLocationTypes{ + "customlocation": ExtendedLocationTypesCustomLocation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExtendedLocationTypes(input) + return &out, nil +} + +type OperatingSystemTypes string + +const ( + OperatingSystemTypesLinux OperatingSystemTypes = "Linux" + OperatingSystemTypesWindows OperatingSystemTypes = "Windows" +) + +func PossibleValuesForOperatingSystemTypes() []string { + return []string{ + string(OperatingSystemTypesLinux), + string(OperatingSystemTypesWindows), + } +} + +func (s *OperatingSystemTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperatingSystemTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperatingSystemTypes(input string) (*OperatingSystemTypes, error) { + vals := map[string]OperatingSystemTypes{ + "linux": OperatingSystemTypesLinux, + "windows": OperatingSystemTypesWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperatingSystemTypes(input) + return &out, nil +} + +type PowerStateEnum string + +const ( + PowerStateEnumDeallocated PowerStateEnum = "Deallocated" + PowerStateEnumDeallocating PowerStateEnum = "Deallocating" + PowerStateEnumRunning PowerStateEnum = "Running" + PowerStateEnumStarting PowerStateEnum = "Starting" + PowerStateEnumStopped PowerStateEnum = "Stopped" + PowerStateEnumStopping PowerStateEnum = "Stopping" + PowerStateEnumUnknown PowerStateEnum = "Unknown" +) + +func PossibleValuesForPowerStateEnum() []string { + return []string{ + string(PowerStateEnumDeallocated), + string(PowerStateEnumDeallocating), + string(PowerStateEnumRunning), + string(PowerStateEnumStarting), + string(PowerStateEnumStopped), + string(PowerStateEnumStopping), + string(PowerStateEnumUnknown), + } +} + +func (s *PowerStateEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePowerStateEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePowerStateEnum(input string) (*PowerStateEnum, error) { + vals := map[string]PowerStateEnum{ + "deallocated": PowerStateEnumDeallocated, + "deallocating": PowerStateEnumDeallocating, + "running": PowerStateEnumRunning, + "starting": PowerStateEnumStarting, + "stopped": PowerStateEnumStopped, + "stopping": PowerStateEnumStopping, + "unknown": PowerStateEnumUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PowerStateEnum(input) + return &out, nil +} + +type ProvisioningStateEnum string + +const ( + ProvisioningStateEnumAccepted ProvisioningStateEnum = "Accepted" + ProvisioningStateEnumCanceled ProvisioningStateEnum = "Canceled" + ProvisioningStateEnumDeleting ProvisioningStateEnum = "Deleting" + ProvisioningStateEnumFailed ProvisioningStateEnum = "Failed" + ProvisioningStateEnumInProgress ProvisioningStateEnum = "InProgress" + ProvisioningStateEnumSucceeded ProvisioningStateEnum = "Succeeded" +) + +func PossibleValuesForProvisioningStateEnum() []string { + return []string{ + string(ProvisioningStateEnumAccepted), + string(ProvisioningStateEnumCanceled), + string(ProvisioningStateEnumDeleting), + string(ProvisioningStateEnumFailed), + string(ProvisioningStateEnumInProgress), + string(ProvisioningStateEnumSucceeded), + } +} + +func (s *ProvisioningStateEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningStateEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningStateEnum(input string) (*ProvisioningStateEnum, error) { + vals := map[string]ProvisioningStateEnum{ + "accepted": ProvisioningStateEnumAccepted, + "canceled": ProvisioningStateEnumCanceled, + "deleting": ProvisioningStateEnumDeleting, + "failed": ProvisioningStateEnumFailed, + "inprogress": ProvisioningStateEnumInProgress, + "succeeded": ProvisioningStateEnumSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningStateEnum(input) + return &out, nil +} + +type SecurityTypes string + +const ( + SecurityTypesConfidentialVM SecurityTypes = "ConfidentialVM" + SecurityTypesTrustedLaunch SecurityTypes = "TrustedLaunch" +) + +func PossibleValuesForSecurityTypes() []string { + return []string{ + string(SecurityTypesConfidentialVM), + string(SecurityTypesTrustedLaunch), + } +} + +func (s *SecurityTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityTypes(input string) (*SecurityTypes, error) { + vals := map[string]SecurityTypes{ + "confidentialvm": SecurityTypesConfidentialVM, + "trustedlaunch": SecurityTypesTrustedLaunch, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityTypes(input) + return &out, nil +} + +type Status string + +const ( + StatusFailed Status = "Failed" + StatusInProgress Status = "InProgress" + StatusSucceeded Status = "Succeeded" +) + +func PossibleValuesForStatus() []string { + return []string{ + string(StatusFailed), + string(StatusInProgress), + string(StatusSucceeded), + } +} + +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatus(input string) (*Status, error) { + vals := map[string]Status{ + "failed": StatusFailed, + "inprogress": StatusInProgress, + "succeeded": StatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Status(input) + return &out, nil +} + +type StatusLevelTypes string + +const ( + StatusLevelTypesError StatusLevelTypes = "Error" + StatusLevelTypesInfo StatusLevelTypes = "Info" + StatusLevelTypesWarning StatusLevelTypes = "Warning" +) + +func PossibleValuesForStatusLevelTypes() []string { + return []string{ + string(StatusLevelTypesError), + string(StatusLevelTypesInfo), + string(StatusLevelTypesWarning), + } +} + +func (s *StatusLevelTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatusLevelTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatusLevelTypes(input string) (*StatusLevelTypes, error) { + vals := map[string]StatusLevelTypes{ + "error": StatusLevelTypesError, + "info": StatusLevelTypesInfo, + "warning": StatusLevelTypesWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StatusLevelTypes(input) + return &out, nil +} + +type StatusTypes string + +const ( + StatusTypesFailed StatusTypes = "Failed" + StatusTypesInProgress StatusTypes = "InProgress" + StatusTypesSucceeded StatusTypes = "Succeeded" +) + +func PossibleValuesForStatusTypes() []string { + return []string{ + string(StatusTypesFailed), + string(StatusTypesInProgress), + string(StatusTypesSucceeded), + } +} + +func (s *StatusTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatusTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatusTypes(input string) (*StatusTypes, error) { + vals := map[string]StatusTypes{ + "failed": StatusTypesFailed, + "inprogress": StatusTypesInProgress, + "succeeded": StatusTypesSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StatusTypes(input) + return &out, nil +} + +type VMSizeEnum string + +const ( + VMSizeEnumCustom VMSizeEnum = "Custom" + VMSizeEnumDefault VMSizeEnum = "Default" + VMSizeEnumStandardAFourVTwo VMSizeEnum = "Standard_A4_v2" + VMSizeEnumStandardATwoVTwo VMSizeEnum = "Standard_A2_v2" + VMSizeEnumStandardDEightsVThree VMSizeEnum = "Standard_D8s_v3" + VMSizeEnumStandardDFoursVThree VMSizeEnum = "Standard_D4s_v3" + VMSizeEnumStandardDOneSixsVThree VMSizeEnum = "Standard_D16s_v3" + VMSizeEnumStandardDSFiveVTwo VMSizeEnum = "Standard_DS5_v2" + VMSizeEnumStandardDSFourVTwo VMSizeEnum = "Standard_DS4_v2" + VMSizeEnumStandardDSOneThreeVTwo VMSizeEnum = "Standard_DS13_v2" + VMSizeEnumStandardDSThreeVTwo VMSizeEnum = "Standard_DS3_v2" + VMSizeEnumStandardDSTwoVTwo VMSizeEnum = "Standard_DS2_v2" + VMSizeEnumStandardDThreeTwosVThree VMSizeEnum = "Standard_D32s_v3" + VMSizeEnumStandardDTwosVThree VMSizeEnum = "Standard_D2s_v3" + VMSizeEnumStandardKEightSFiveVOne VMSizeEnum = "Standard_K8S5_v1" + VMSizeEnumStandardKEightSFourVOne VMSizeEnum = "Standard_K8S4_v1" + VMSizeEnumStandardKEightSThreeVOne VMSizeEnum = "Standard_K8S3_v1" + VMSizeEnumStandardKEightSTwoVOne VMSizeEnum = "Standard_K8S2_v1" + VMSizeEnumStandardKEightSVOne VMSizeEnum = "Standard_K8S_v1" + VMSizeEnumStandardNKOneTwo VMSizeEnum = "Standard_NK12" + VMSizeEnumStandardNKSix VMSizeEnum = "Standard_NK6" + VMSizeEnumStandardNVOneTwo VMSizeEnum = "Standard_NV12" + VMSizeEnumStandardNVSix VMSizeEnum = "Standard_NV6" +) + +func PossibleValuesForVMSizeEnum() []string { + return []string{ + string(VMSizeEnumCustom), + string(VMSizeEnumDefault), + string(VMSizeEnumStandardAFourVTwo), + string(VMSizeEnumStandardATwoVTwo), + string(VMSizeEnumStandardDEightsVThree), + string(VMSizeEnumStandardDFoursVThree), + string(VMSizeEnumStandardDOneSixsVThree), + string(VMSizeEnumStandardDSFiveVTwo), + string(VMSizeEnumStandardDSFourVTwo), + string(VMSizeEnumStandardDSOneThreeVTwo), + string(VMSizeEnumStandardDSThreeVTwo), + string(VMSizeEnumStandardDSTwoVTwo), + string(VMSizeEnumStandardDThreeTwosVThree), + string(VMSizeEnumStandardDTwosVThree), + string(VMSizeEnumStandardKEightSFiveVOne), + string(VMSizeEnumStandardKEightSFourVOne), + string(VMSizeEnumStandardKEightSThreeVOne), + string(VMSizeEnumStandardKEightSTwoVOne), + string(VMSizeEnumStandardKEightSVOne), + string(VMSizeEnumStandardNKOneTwo), + string(VMSizeEnumStandardNKSix), + string(VMSizeEnumStandardNVOneTwo), + string(VMSizeEnumStandardNVSix), + } +} + +func (s *VMSizeEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVMSizeEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVMSizeEnum(input string) (*VMSizeEnum, error) { + vals := map[string]VMSizeEnum{ + "custom": VMSizeEnumCustom, + "default": VMSizeEnumDefault, + "standard_a4_v2": VMSizeEnumStandardAFourVTwo, + "standard_a2_v2": VMSizeEnumStandardATwoVTwo, + "standard_d8s_v3": VMSizeEnumStandardDEightsVThree, + "standard_d4s_v3": VMSizeEnumStandardDFoursVThree, + "standard_d16s_v3": VMSizeEnumStandardDOneSixsVThree, + "standard_ds5_v2": VMSizeEnumStandardDSFiveVTwo, + "standard_ds4_v2": VMSizeEnumStandardDSFourVTwo, + "standard_ds13_v2": VMSizeEnumStandardDSOneThreeVTwo, + "standard_ds3_v2": VMSizeEnumStandardDSThreeVTwo, + "standard_ds2_v2": VMSizeEnumStandardDSTwoVTwo, + "standard_d32s_v3": VMSizeEnumStandardDThreeTwosVThree, + "standard_d2s_v3": VMSizeEnumStandardDTwosVThree, + "standard_k8s5_v1": VMSizeEnumStandardKEightSFiveVOne, + "standard_k8s4_v1": VMSizeEnumStandardKEightSFourVOne, + "standard_k8s3_v1": VMSizeEnumStandardKEightSThreeVOne, + "standard_k8s2_v1": VMSizeEnumStandardKEightSTwoVOne, + "standard_k8s_v1": VMSizeEnumStandardKEightSVOne, + "standard_nk12": VMSizeEnumStandardNKOneTwo, + "standard_nk6": VMSizeEnumStandardNKSix, + "standard_nv12": VMSizeEnumStandardNVOneTwo, + "standard_nv6": VMSizeEnumStandardNVSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VMSizeEnum(input) + return &out, nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_createorupdate.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_createorupdate.go new file mode 100644 index 00000000000..93c2bdc8666 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_createorupdate.go @@ -0,0 +1,75 @@ +package virtualmachineinstances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdate ... +func (c VirtualMachineInstancesClient) CreateOrUpdate(ctx context.Context, id commonids.ScopeId, input VirtualMachineInstance) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c VirtualMachineInstancesClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.ScopeId, input VirtualMachineInstance) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_delete.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_delete.go new file mode 100644 index 00000000000..e71f0c564c7 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_delete.go @@ -0,0 +1,71 @@ +package virtualmachineinstances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c VirtualMachineInstancesClient) Delete(ctx context.Context, id commonids.ScopeId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c VirtualMachineInstancesClient) DeleteThenPoll(ctx context.Context, id commonids.ScopeId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_get.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_get.go new file mode 100644 index 00000000000..d7da3a445fc --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_get.go @@ -0,0 +1,53 @@ +package virtualmachineinstances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualMachineInstance +} + +// Get ... +func (c VirtualMachineInstancesClient) Get(ctx context.Context, id commonids.ScopeId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_list.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_list.go new file mode 100644 index 00000000000..266c91df4a1 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_list.go @@ -0,0 +1,92 @@ +package virtualmachineinstances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualMachineInstance +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualMachineInstance +} + +// List ... +func (c VirtualMachineInstancesClient) List(ctx context.Context, id commonids.ScopeId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/virtualMachineInstances", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualMachineInstance `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c VirtualMachineInstancesClient) ListComplete(ctx context.Context, id commonids.ScopeId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, VirtualMachineInstanceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualMachineInstancesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ScopeId, predicate VirtualMachineInstanceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]VirtualMachineInstance, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_restart.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_restart.go new file mode 100644 index 00000000000..575d91ef3a1 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_restart.go @@ -0,0 +1,71 @@ +package virtualmachineinstances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Restart ... +func (c VirtualMachineInstancesClient) Restart(ctx context.Context, id commonids.ScopeId) (result RestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/restart", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestartThenPoll performs Restart then polls until it's completed +func (c VirtualMachineInstancesClient) RestartThenPoll(ctx context.Context, id commonids.ScopeId) error { + result, err := c.Restart(ctx, id) + if err != nil { + return fmt.Errorf("performing Restart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Restart: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_start.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_start.go new file mode 100644 index 00000000000..8b59e62a0d3 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_start.go @@ -0,0 +1,71 @@ +package virtualmachineinstances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Start ... +func (c VirtualMachineInstancesClient) Start(ctx context.Context, id commonids.ScopeId) (result StartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StartThenPoll performs Start then polls until it's completed +func (c VirtualMachineInstancesClient) StartThenPoll(ctx context.Context, id commonids.ScopeId) error { + result, err := c.Start(ctx, id) + if err != nil { + return fmt.Errorf("performing Start: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Start: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_stop.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_stop.go new file mode 100644 index 00000000000..fa7f792cce2 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_stop.go @@ -0,0 +1,71 @@ +package virtualmachineinstances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Stop ... +func (c VirtualMachineInstancesClient) Stop(ctx context.Context, id commonids.ScopeId) (result StopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StopThenPoll performs Stop then polls until it's completed +func (c VirtualMachineInstancesClient) StopThenPoll(ctx context.Context, id commonids.ScopeId) error { + result, err := c.Stop(ctx, id) + if err != nil { + return fmt.Errorf("performing Stop: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Stop: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_update.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_update.go new file mode 100644 index 00000000000..fdd7b641d95 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/method_update.go @@ -0,0 +1,75 @@ +package virtualmachineinstances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c VirtualMachineInstancesClient) Update(ctx context.Context, id commonids.ScopeId, input VirtualMachineInstanceUpdateRequest) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c VirtualMachineInstancesClient) UpdateThenPoll(ctx context.Context, id commonids.ScopeId, input VirtualMachineInstanceUpdateRequest) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_erroradditionalinfo.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_erroradditionalinfo.go new file mode 100644 index 00000000000..4bc54a9ce01 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_errordetail.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_errordetail.go new file mode 100644 index 00000000000..27f74262121 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_errordetail.go @@ -0,0 +1,12 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_extendedlocation.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_extendedlocation.go new file mode 100644 index 00000000000..91c570023b0 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_extendedlocation.go @@ -0,0 +1,9 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *ExtendedLocationTypes `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_guestagentinstallstatus.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_guestagentinstallstatus.go new file mode 100644 index 00000000000..d840ed26b08 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_guestagentinstallstatus.go @@ -0,0 +1,30 @@ +package virtualmachineinstances + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GuestAgentInstallStatus struct { + AgentVersion *string `json:"agentVersion,omitempty"` + ErrorDetails *[]ErrorDetail `json:"errorDetails,omitempty"` + LastStatusChange *string `json:"lastStatusChange,omitempty"` + Status *StatusTypes `json:"status,omitempty"` + VMUuid *string `json:"vmUuid,omitempty"` +} + +func (o *GuestAgentInstallStatus) GetLastStatusChangeAsTime() (*time.Time, error) { + if o.LastStatusChange == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastStatusChange, "2006-01-02T15:04:05Z07:00") +} + +func (o *GuestAgentInstallStatus) SetLastStatusChangeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastStatusChange = &formatted +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_hardwareprofileupdate.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_hardwareprofileupdate.go new file mode 100644 index 00000000000..8ac33a2aac2 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_hardwareprofileupdate.go @@ -0,0 +1,10 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HardwareProfileUpdate struct { + MemoryMB *int64 `json:"memoryMB,omitempty"` + Processors *int64 `json:"processors,omitempty"` + VMSize *VMSizeEnum `json:"vmSize,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_httpproxyconfiguration.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_httpproxyconfiguration.go new file mode 100644 index 00000000000..e6b9fe48464 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_httpproxyconfiguration.go @@ -0,0 +1,11 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPProxyConfiguration struct { + HTTPProxy *string `json:"httpProxy,omitempty"` + HTTPSProxy *string `json:"httpsProxy,omitempty"` + NoProxy *[]string `json:"noProxy,omitempty"` + TrustedCa *string `json:"trustedCa,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_instanceviewstatus.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_instanceviewstatus.go new file mode 100644 index 00000000000..cf090359480 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_instanceviewstatus.go @@ -0,0 +1,30 @@ +package virtualmachineinstances + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InstanceViewStatus struct { + Code *string `json:"code,omitempty"` + DisplayStatus *string `json:"displayStatus,omitempty"` + Level *StatusLevelTypes `json:"level,omitempty"` + Message *string `json:"message,omitempty"` + Time *string `json:"time,omitempty"` +} + +func (o *InstanceViewStatus) GetTimeAsTime() (*time.Time, error) { + if o.Time == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Time, "2006-01-02T15:04:05Z07:00") +} + +func (o *InstanceViewStatus) SetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Time = &formatted +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_networkprofileupdate.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_networkprofileupdate.go new file mode 100644 index 00000000000..38d8b2ce83b --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_networkprofileupdate.go @@ -0,0 +1,8 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkProfileUpdate struct { + NetworkInterfaces *[]NetworkProfileUpdateNetworkInterfacesInlined `json:"networkInterfaces,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_networkprofileupdatenetworkinterfacesinlined.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_networkprofileupdatenetworkinterfacesinlined.go new file mode 100644 index 00000000000..06e4797a9eb --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_networkprofileupdatenetworkinterfacesinlined.go @@ -0,0 +1,8 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkProfileUpdateNetworkInterfacesInlined struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_osprofileupdate.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_osprofileupdate.go new file mode 100644 index 00000000000..68fb327421e --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_osprofileupdate.go @@ -0,0 +1,10 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OsProfileUpdate struct { + ComputerName *string `json:"computerName,omitempty"` + LinuxConfiguration *OsProfileUpdateLinuxConfiguration `json:"linuxConfiguration,omitempty"` + WindowsConfiguration *OsProfileUpdateWindowsConfiguration `json:"windowsConfiguration,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_osprofileupdatelinuxconfiguration.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_osprofileupdatelinuxconfiguration.go new file mode 100644 index 00000000000..771d0cad563 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_osprofileupdatelinuxconfiguration.go @@ -0,0 +1,9 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OsProfileUpdateLinuxConfiguration struct { + ProvisionVMAgent *bool `json:"provisionVMAgent,omitempty"` + ProvisionVMConfigAgent *bool `json:"provisionVMConfigAgent,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_osprofileupdatewindowsconfiguration.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_osprofileupdatewindowsconfiguration.go new file mode 100644 index 00000000000..556f6158585 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_osprofileupdatewindowsconfiguration.go @@ -0,0 +1,9 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OsProfileUpdateWindowsConfiguration struct { + ProvisionVMAgent *bool `json:"provisionVMAgent,omitempty"` + ProvisionVMConfigAgent *bool `json:"provisionVMConfigAgent,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_sshconfiguration.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_sshconfiguration.go new file mode 100644 index 00000000000..65cfc412539 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_sshconfiguration.go @@ -0,0 +1,8 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SshConfiguration struct { + PublicKeys *[]SshPublicKey `json:"publicKeys,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_sshpublickey.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_sshpublickey.go new file mode 100644 index 00000000000..24b2239ea7e --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_sshpublickey.go @@ -0,0 +1,9 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SshPublicKey struct { + KeyData *string `json:"keyData,omitempty"` + Path *string `json:"path,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_storageprofileupdate.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_storageprofileupdate.go new file mode 100644 index 00000000000..f9315c680f4 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_storageprofileupdate.go @@ -0,0 +1,8 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageProfileUpdate struct { + DataDisks *[]StorageProfileUpdateDataDisksInlined `json:"dataDisks,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_storageprofileupdatedatadisksinlined.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_storageprofileupdatedatadisksinlined.go new file mode 100644 index 00000000000..53c62f6a338 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_storageprofileupdatedatadisksinlined.go @@ -0,0 +1,8 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageProfileUpdateDataDisksInlined struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineconfigagentinstanceview.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineconfigagentinstanceview.go new file mode 100644 index 00000000000..17a3de99b14 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineconfigagentinstanceview.go @@ -0,0 +1,9 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineConfigAgentInstanceView struct { + Statuses *[]InstanceViewStatus `json:"statuses,omitempty"` + VMConfigAgentVersion *string `json:"vmConfigAgentVersion,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstance.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstance.go new file mode 100644 index 00000000000..c7042f00115 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstance.go @@ -0,0 +1,19 @@ +package virtualmachineinstances + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstance struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAssigned `json:"identity,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualMachineInstanceProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstanceproperties.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstanceproperties.go new file mode 100644 index 00000000000..2958663da50 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstanceproperties.go @@ -0,0 +1,19 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstanceProperties struct { + GuestAgentInstallStatus *GuestAgentInstallStatus `json:"guestAgentInstallStatus,omitempty"` + HTTPProxyConfig *HTTPProxyConfiguration `json:"httpProxyConfig,omitempty"` + HardwareProfile *VirtualMachineInstancePropertiesHardwareProfile `json:"hardwareProfile,omitempty"` + InstanceView *VirtualMachineInstanceView `json:"instanceView,omitempty"` + NetworkProfile *VirtualMachineInstancePropertiesNetworkProfile `json:"networkProfile,omitempty"` + OsProfile *VirtualMachineInstancePropertiesOsProfile `json:"osProfile,omitempty"` + ProvisioningState *ProvisioningStateEnum `json:"provisioningState,omitempty"` + ResourceUid *string `json:"resourceUid,omitempty"` + SecurityProfile *VirtualMachineInstancePropertiesSecurityProfile `json:"securityProfile,omitempty"` + Status *VirtualMachineInstanceStatus `json:"status,omitempty"` + StorageProfile *VirtualMachineInstancePropertiesStorageProfile `json:"storageProfile,omitempty"` + VMId *string `json:"vmId,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertieshardwareprofile.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertieshardwareprofile.go new file mode 100644 index 00000000000..6477a3e0e82 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertieshardwareprofile.go @@ -0,0 +1,11 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstancePropertiesHardwareProfile struct { + DynamicMemoryConfig *VirtualMachineInstancePropertiesHardwareProfileDynamicMemoryConfig `json:"dynamicMemoryConfig,omitempty"` + MemoryMB *int64 `json:"memoryMB,omitempty"` + Processors *int64 `json:"processors,omitempty"` + VMSize *VMSizeEnum `json:"vmSize,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertieshardwareprofiledynamicmemoryconfig.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertieshardwareprofiledynamicmemoryconfig.go new file mode 100644 index 00000000000..71edd879165 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertieshardwareprofiledynamicmemoryconfig.go @@ -0,0 +1,10 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstancePropertiesHardwareProfileDynamicMemoryConfig struct { + MaximumMemoryMB *int64 `json:"maximumMemoryMB,omitempty"` + MinimumMemoryMB *int64 `json:"minimumMemoryMB,omitempty"` + TargetMemoryBuffer *int64 `json:"targetMemoryBuffer,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesnetworkprofile.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesnetworkprofile.go new file mode 100644 index 00000000000..66c9a793447 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesnetworkprofile.go @@ -0,0 +1,8 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstancePropertiesNetworkProfile struct { + NetworkInterfaces *[]VirtualMachineInstancePropertiesNetworkProfileNetworkInterfacesInlined `json:"networkInterfaces,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesnetworkprofilenetworkinterfacesinlined.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesnetworkprofilenetworkinterfacesinlined.go new file mode 100644 index 00000000000..4b7bfad467f --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesnetworkprofilenetworkinterfacesinlined.go @@ -0,0 +1,8 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstancePropertiesNetworkProfileNetworkInterfacesInlined struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesosprofile.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesosprofile.go new file mode 100644 index 00000000000..9e3a604396d --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesosprofile.go @@ -0,0 +1,12 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstancePropertiesOsProfile struct { + AdminPassword *string `json:"adminPassword,omitempty"` + AdminUsername *string `json:"adminUsername,omitempty"` + ComputerName *string `json:"computerName,omitempty"` + LinuxConfiguration *VirtualMachineInstancePropertiesOsProfileLinuxConfiguration `json:"linuxConfiguration,omitempty"` + WindowsConfiguration *VirtualMachineInstancePropertiesOsProfileWindowsConfiguration `json:"windowsConfiguration,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesosprofilelinuxconfiguration.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesosprofilelinuxconfiguration.go new file mode 100644 index 00000000000..795bef56661 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesosprofilelinuxconfiguration.go @@ -0,0 +1,11 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstancePropertiesOsProfileLinuxConfiguration struct { + DisablePasswordAuthentication *bool `json:"disablePasswordAuthentication,omitempty"` + ProvisionVMAgent *bool `json:"provisionVMAgent,omitempty"` + ProvisionVMConfigAgent *bool `json:"provisionVMConfigAgent,omitempty"` + Ssh *SshConfiguration `json:"ssh,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesosprofilewindowsconfiguration.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesosprofilewindowsconfiguration.go new file mode 100644 index 00000000000..bee8ebecd07 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesosprofilewindowsconfiguration.go @@ -0,0 +1,12 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstancePropertiesOsProfileWindowsConfiguration struct { + EnableAutomaticUpdates *bool `json:"enableAutomaticUpdates,omitempty"` + ProvisionVMAgent *bool `json:"provisionVMAgent,omitempty"` + ProvisionVMConfigAgent *bool `json:"provisionVMConfigAgent,omitempty"` + Ssh *SshConfiguration `json:"ssh,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiessecurityprofile.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiessecurityprofile.go new file mode 100644 index 00000000000..606e35a685c --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiessecurityprofile.go @@ -0,0 +1,10 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstancePropertiesSecurityProfile struct { + EnableTPM *bool `json:"enableTPM,omitempty"` + SecurityType *SecurityTypes `json:"securityType,omitempty"` + UefiSettings *VirtualMachineInstancePropertiesSecurityProfileUefiSettings `json:"uefiSettings,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiessecurityprofileuefisettings.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiessecurityprofileuefisettings.go new file mode 100644 index 00000000000..575c3806034 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiessecurityprofileuefisettings.go @@ -0,0 +1,8 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstancePropertiesSecurityProfileUefiSettings struct { + SecureBootEnabled *bool `json:"secureBootEnabled,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesstorageprofile.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesstorageprofile.go new file mode 100644 index 00000000000..a3ca01aa2f3 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesstorageprofile.go @@ -0,0 +1,11 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstancePropertiesStorageProfile struct { + DataDisks *[]VirtualMachineInstancePropertiesStorageProfileDataDisksInlined `json:"dataDisks,omitempty"` + ImageReference *VirtualMachineInstancePropertiesStorageProfileImageReference `json:"imageReference,omitempty"` + OsDisk *VirtualMachineInstancePropertiesStorageProfileOsDisk `json:"osDisk,omitempty"` + VMConfigStoragePathId *string `json:"vmConfigStoragePathId,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesstorageprofiledatadisksinlined.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesstorageprofiledatadisksinlined.go new file mode 100644 index 00000000000..e53aab331c1 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesstorageprofiledatadisksinlined.go @@ -0,0 +1,8 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstancePropertiesStorageProfileDataDisksInlined struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesstorageprofileimagereference.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesstorageprofileimagereference.go new file mode 100644 index 00000000000..e2b09c81d5b --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesstorageprofileimagereference.go @@ -0,0 +1,8 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstancePropertiesStorageProfileImageReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesstorageprofileosdisk.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesstorageprofileosdisk.go new file mode 100644 index 00000000000..a2817dfd294 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancepropertiesstorageprofileosdisk.go @@ -0,0 +1,9 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstancePropertiesStorageProfileOsDisk struct { + Id *string `json:"id,omitempty"` + OsType *OperatingSystemTypes `json:"osType,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancestatus.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancestatus.go new file mode 100644 index 00000000000..692614617be --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancestatus.go @@ -0,0 +1,11 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstanceStatus struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + PowerState *PowerStateEnum `json:"powerState,omitempty"` + ProvisioningStatus *VirtualMachineInstanceStatusProvisioningStatus `json:"provisioningStatus,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancestatusprovisioningstatus.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancestatusprovisioningstatus.go new file mode 100644 index 00000000000..01216f61012 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstancestatusprovisioningstatus.go @@ -0,0 +1,9 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstanceStatusProvisioningStatus struct { + OperationId *string `json:"operationId,omitempty"` + Status *Status `json:"status,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstanceupdateproperties.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstanceupdateproperties.go new file mode 100644 index 00000000000..3cef824dba6 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstanceupdateproperties.go @@ -0,0 +1,11 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstanceUpdateProperties struct { + HardwareProfile *HardwareProfileUpdate `json:"hardwareProfile,omitempty"` + NetworkProfile *NetworkProfileUpdate `json:"networkProfile,omitempty"` + OsProfile *OsProfileUpdate `json:"osProfile,omitempty"` + StorageProfile *StorageProfileUpdate `json:"storageProfile,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstanceupdaterequest.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstanceupdaterequest.go new file mode 100644 index 00000000000..4bc62e74041 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstanceupdaterequest.go @@ -0,0 +1,13 @@ +package virtualmachineinstances + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstanceUpdateRequest struct { + Identity *identity.SystemAssigned `json:"identity,omitempty"` + Properties *VirtualMachineInstanceUpdateProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstanceview.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstanceview.go new file mode 100644 index 00000000000..06414a259e5 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/model_virtualmachineinstanceview.go @@ -0,0 +1,8 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstanceView struct { + VMAgent *VirtualMachineConfigAgentInstanceView `json:"vmAgent,omitempty"` +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/predicates.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/predicates.go new file mode 100644 index 00000000000..e4d7d84f357 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/predicates.go @@ -0,0 +1,27 @@ +package virtualmachineinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineInstanceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p VirtualMachineInstanceOperationPredicate) Matches(input VirtualMachineInstance) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/version.go b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/version.go new file mode 100644 index 00000000000..366beef0998 --- /dev/null +++ b/resource-manager/azurestackhci/2023-09-01-preview/virtualmachineinstances/version.go @@ -0,0 +1,12 @@ +package virtualmachineinstances + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-01-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/virtualmachineinstances/%s", defaultApiVersion) +}